Skip to content

Commit 92702b9

Browse files
committed
build: remove nose test framework
1 parent 94bb81f commit 92702b9

22 files changed

+255
-537
lines changed

tests/all_elements_tests.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,33 @@
1-
from nose.tools import istest, assert_equal
21

32
from precisely import all_elements, equal_to
43
from precisely.results import matched, unmatched
54

65

7-
@istest
8-
def matches_when_all_items_in_iterable_match():
6+
def test_matches_when_all_items_in_iterable_match():
97
matcher = all_elements(equal_to("apple"))
108

11-
assert_equal(matched(), matcher.match(["apple", "apple"]))
9+
assert matched() == matcher.match(["apple", "apple"])
1210

1311

14-
@istest
15-
def mismatches_when_actual_is_not_iterable():
12+
def test_mismatches_when_actual_is_not_iterable():
1613
matcher = all_elements(equal_to("apple"))
1714

18-
assert_equal(
19-
unmatched("was not iterable\nwas 0"),
20-
matcher.match(0)
21-
)
15+
assert unmatched("was not iterable\nwas 0") == matcher.match(0)
2216

2317

24-
@istest
25-
def mismatches_when_item_in_iterable_does_not_match():
18+
def test_mismatches_when_item_in_iterable_does_not_match():
2619
matcher = all_elements(equal_to("apple"))
2720

28-
assert_equal(
29-
unmatched("element at index 1 mismatched: was 'orange'"),
30-
matcher.match(["apple", "orange"])
31-
)
21+
assert unmatched("element at index 1 mismatched: was 'orange'") == matcher.match(["apple", "orange"])
3222

3323

34-
@istest
35-
def matches_when_iterable_is_empty():
24+
def test_matches_when_iterable_is_empty():
3625
matcher = all_elements(equal_to("apple"))
3726

38-
assert_equal(matched(), matcher.match([]))
27+
assert matched() == matcher.match([])
3928

4029

41-
@istest
42-
def description_contains_descriptions_of_submatcher():
30+
def test_description_contains_descriptions_of_submatcher():
4331
matcher = all_elements(equal_to("apple"))
4432

45-
assert_equal(
46-
"all elements of iterable match: 'apple'",
47-
matcher.describe()
48-
)
33+
assert "all elements of iterable match: 'apple'" == matcher.describe()

tests/all_of_tests.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,35 @@
11
import collections
22

3-
from nose.tools import istest, assert_equal
43

54
from precisely import all_of, has_attr, equal_to
65
from precisely.results import matched, unmatched
76

87

98
User = collections.namedtuple("User", ["username", "email_address"])
109

11-
@istest
12-
def matches_when_submatchers_all_match():
10+
def test_matches_when_submatchers_all_match():
1311
matcher = all_of(
1412
has_attr("username", equal_to("bob")),
1513
has_attr("email_address", equal_to("bob@example.com")),
1614
)
17-
18-
assert_equal(matched(), matcher.match(User("bob", "bob@example.com")))
1915

16+
assert matched() == matcher.match(User("bob", "bob@example.com"))
2017

21-
@istest
22-
def mismatches_when_submatcher_mismatches():
18+
19+
def test_mismatches_when_submatcher_mismatches():
2320
matcher = all_of(
2421
has_attr("username", equal_to("bob")),
2522
has_attr("email_address", equal_to("bob@example.com")),
2623
)
27-
28-
assert_equal(
29-
unmatched("was missing attribute username"),
30-
matcher.match("bobbity")
31-
)
24+
25+
assert unmatched("was missing attribute username") == matcher.match("bobbity")
3226

3327

34-
@istest
35-
def description_contains_descriptions_of_submatchers():
28+
def test_description_contains_descriptions_of_submatchers():
3629
matcher = all_of(
3730
has_attr("username", equal_to("bob")),
3831
has_attr("email_address", equal_to("bob@example.com")),
3932
)
40-
41-
assert_equal(
42-
"all of:\n * object with attribute username: 'bob'\n * object with attribute email_address: 'bob@example.com'",
43-
matcher.describe()
44-
)
33+
34+
assert "all of:\n * object with attribute username: 'bob'\n * object with attribute email_address: 'bob@example.com'" == matcher.describe()
4535

tests/any_of_tests.py

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,44 @@
11
import collections
22

3-
from nose.tools import istest, assert_equal
43

54
from precisely import any_of, has_attr, equal_to
65
from precisely.results import matched, unmatched
76

87

98
User = collections.namedtuple("User", ["username", "email_address"])
109

11-
@istest
12-
def matches_when_submatchers_all_match():
10+
def test_matches_when_submatchers_all_match():
1311
matcher = any_of(
1412
has_attr("username", equal_to("bob")),
1513
has_attr("email_address", equal_to("bob@example.com")),
1614
)
17-
18-
assert_equal(matched(), matcher.match(User("bob", "bob@example.com")))
1915

16+
assert matched() == matcher.match(User("bob", "bob@example.com"))
2017

21-
@istest
22-
def matches_when_any_submatchers_match():
18+
19+
def test_matches_when_any_submatchers_match():
2320
matcher = any_of(
2421
equal_to("bob"),
2522
equal_to("jim"),
2623
)
27-
28-
assert_equal(
29-
matched(),
30-
matcher.match("bob"),
31-
)
3224

25+
assert matched() == matcher.match("bob")
3326

34-
@istest
35-
def mismatches_when_no_submatchers_match():
27+
28+
def test_mismatches_when_no_submatchers_match():
3629
matcher = any_of(
3730
equal_to("bob"),
3831
equal_to("jim"),
3932
)
40-
41-
assert_equal(
42-
unmatched("did not match any of:\n * 'bob' [was 'alice']\n * 'jim' [was 'alice']"),
43-
matcher.match("alice"),
44-
)
4533

34+
assert unmatched("did not match any of:\n * 'bob' [was 'alice']\n * 'jim' [was 'alice']") == matcher.match("alice")
4635

47-
@istest
48-
def description_contains_descriptions_of_submatchers():
36+
37+
def test_description_contains_descriptions_of_submatchers():
4938
matcher = any_of(
5039
has_attr("username", equal_to("bob")),
5140
has_attr("email_address", equal_to("bob@example.com")),
5241
)
53-
54-
assert_equal(
55-
"any of:\n * object with attribute username: 'bob'\n * object with attribute email_address: 'bob@example.com'",
56-
matcher.describe()
57-
)
42+
43+
assert "any of:\n * object with attribute username: 'bob'\n * object with attribute email_address: 'bob@example.com'" == matcher.describe()
5844

tests/anything_tests.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
from nose.tools import istest, assert_equal
21

32
from precisely import anything
43
from precisely.results import matched
54

65

7-
@istest
8-
def matches_anything():
9-
assert_equal(matched(), anything.match(4))
10-
assert_equal(matched(), anything.match(None))
11-
assert_equal(matched(), anything.match("Hello"))
6+
def test_matches_anything():
7+
assert matched() == anything.match(4)
8+
assert matched() == anything.match(None)
9+
assert matched() == anything.match("Hello")
1210

1311

14-
@istest
15-
def description_is_anything():
16-
assert_equal("anything", anything.describe())
12+
def test_description_is_anything():
13+
assert "anything" == anything.describe()
1714

tests/assert_that_tests.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
from nose.tools import istest, assert_equal
21

32
from precisely import assert_that, equal_to
43

54

6-
@istest
7-
def assert_that_does_nothing_if_matcher_matches():
5+
def test_assert_that_does_nothing_if_matcher_matches():
86
assert_that(1, equal_to(1))
97

108

11-
@istest
12-
def assert_that_raises_assertion_error_if_match_fails():
9+
def test_assert_that_raises_assertion_error_if_match_fails():
1310
try:
1411
assert_that(1, equal_to(2))
1512
assert False, "Expected AssertionError"
1613
except AssertionError as error:
17-
assert_equal("\nExpected:\n 2\nbut:\n was 1", str(error))
14+
assert "\nExpected:\n 2\nbut:\n was 1" == str(error)

tests/close_to_tests.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import functools
22

3-
from nose.tools import istest, assert_equal
43

54
from precisely import close_to, is_sequence
65
from precisely.results import matched, unmatched
76

87

9-
@istest
10-
def close_to_matches_when_actual_is_close_to_value_plus_delta():
8+
def test_close_to_matches_when_actual_is_close_to_value_plus_delta():
119
matcher = close_to(42, 1)
12-
assert_equal(matched(), matcher.match(43))
13-
assert_equal(matched(), matcher.match(42.5))
14-
assert_equal(matched(), matcher.match(42))
15-
assert_equal(matched(), matcher.match(41.5))
16-
assert_equal(matched(), matcher.match(41))
17-
assert_equal(unmatched("was 40 (2 away from 42)"), matcher.match(40))
10+
assert matched() == matcher.match(43)
11+
assert matched() == matcher.match(42.5)
12+
assert matched() == matcher.match(42)
13+
assert matched() == matcher.match(41.5)
14+
assert matched() == matcher.match(41)
15+
assert unmatched("was 40 (2 away from 42)") == matcher.match(40)
1816

1917

20-
@istest
21-
def close_to_matches_any_types_supporting_comparison_and_addition_and_subtraction():
18+
def test_close_to_matches_any_types_supporting_comparison_and_addition_and_subtraction():
2219
class Instant(object):
2320
def __init__(self, seconds_since_epoch):
2421
self.seconds_since_epoch = seconds_since_epoch
@@ -56,21 +53,19 @@ def __repr__(self):
5653
return "Interval({})".format(self.seconds)
5754

5855
matcher = close_to(Instant(42), Interval(1))
59-
assert_equal(matched(), matcher.match(Instant(43)))
60-
assert_equal(matched(), matcher.match(Instant(42.5)))
61-
assert_equal(matched(), matcher.match(Instant(42)))
62-
assert_equal(matched(), matcher.match(Instant(41.5)))
63-
assert_equal(matched(), matcher.match(Instant(41)))
64-
assert_equal(unmatched("was Instant(40) (Interval(2) away from Instant(42))"), matcher.match(Instant(40)))
56+
assert matched() == matcher.match(Instant(43))
57+
assert matched() == matcher.match(Instant(42.5))
58+
assert matched() == matcher.match(Instant(42))
59+
assert matched() == matcher.match(Instant(41.5))
60+
assert matched() == matcher.match(Instant(41))
61+
assert unmatched("was Instant(40) (Interval(2) away from Instant(42))") == matcher.match(Instant(40))
6562

6663

67-
@istest
68-
def close_to_description_describes_value():
64+
def test_close_to_description_describes_value():
6965
matcher = close_to(42, 1)
70-
assert_equal("close to 42 +/- 1", matcher.describe())
66+
assert "close to 42 +/- 1" == matcher.describe()
7167

7268

73-
@istest
74-
def close_to_can_be_used_in_composite_matcher():
69+
def test_close_to_can_be_used_in_composite_matcher():
7570
matcher = is_sequence("a", "b", close_to(42, 1))
76-
assert_equal(matched(), matcher.match(("a", "b", 42)))
71+
assert matched() == matcher.match(("a", "b", 42))

0 commit comments

Comments
 (0)