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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
| | #! /usr/bin/env avocado-runner-avocado-classless
"""
Self tests for avocado-classless plugins
"""
import types
from avocado_classless.manifest import manifest_add
from avocado_classless.test import (
assert_eq, assert_eq_unordered, assert_in, assert_raises, test
)
@test
def trivial():
pass
@test
def assert_true():
assert True
# Check re-registering a function under a different name
manifest_add(__name__, "trivial2", trivial)
@test
def test_assert_eq():
assert_eq(1, 1)
@test
def test_assert_in():
assert_in(1, [1, 2, 3])
assert_raises(AssertionError, assert_in, 'x', 'hello')
@test
def test_assert_raises():
def boom(exc):
raise exc
assert_raises(ValueError, boom, ValueError)
@test
def test_assert_eq_unordered():
assert_eq_unordered([1, 2, 3], (1, 2, 3))
assert_eq_unordered([1, 2, 3], [2, 3, 1])
assert_eq_unordered([1, 1, 1], (1, 1, 1))
assert_raises(AssertionError, assert_eq_unordered, [1, 2, 3], [1, 2, 4])
assert_raises(AssertionError, assert_eq_unordered, [1, 1], [1, 1, 1])
# Test we report attempting to double register the same test name
@test
def test_double_register():
def double_register():
mod = types.ModuleType('dummy')
manifest_add(mod, "test", trivial)
manifest_add(mod, "test", assert_true)
assert_raises(ValueError, double_register)
|