File: test_easytest.py

package info (click to toggle)
python-easydev 0.13.3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: python: 1,904; makefile: 116; javascript: 49
file content (43 lines) | stat: -rw-r--r-- 816 bytes parent folder | download
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
43
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()