File: test_easytest.py

package info (click to toggle)
python-easydev 0.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 504 kB
  • sloc: python: 2,130; javascript: 49; makefile: 13
file content (42 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from easydev.easytest import *

class A(object):
    pass


def test_trysetattr():
    trysetattr(A, "test", 1, possible=True)
    try:
        trysetattr(A, "test", 1, possible=False)
        assert False
    except:
        assert True


def test_tempfile():
    f = TempFile()
    f.name
    f.delete()

    with TempFile() as fh:
        pass


def test_list_almost_equal():
    assert_list_almost_equal([1,2], [1,2])
    try:
        assert_list_almost_equal([1,2], [1,3])
        assert False
    except:
        assert True
        

    assert_list_almost_equal([1,1], [1, 0.9999], places=3)
    assert_list_almost_equal([1,1], [1, 0.9999], deltas=1e-4)
    try:
        assert_list_almost_equal([1,1], [1, 0.9999], deltas=1e-5)
        assert False
    except:
        assert True

test_list_almost_equal()