##// END OF EJS Templates
Python 2.6: Add `assert_is_none`, `assert_is_not_none` to `nose.tools`.
Bradley M. Froehle -
Show More
@@ -1,17 +1,29
1 """Add some assert methods to nose.tools. These were added in Python 2.7/3.1, so
1 """Add some assert methods to nose.tools. These were added in Python 2.7/3.1, so
2 once we stop testing on Python 2.6, this file can be removed.
2 once we stop testing on Python 2.6, this file can be removed.
3 """
3 """
4
4
5 import nose.tools as nt
5 import nose.tools as nt
6
6
7 def assert_in(item, collection):
7 def assert_in(item, collection):
8 assert item in collection, '%r not in %r' % (item, collection)
8 assert item in collection, '%r not in %r' % (item, collection)
9
9
10 if not hasattr(nt, 'assert_in'):
10 if not hasattr(nt, 'assert_in'):
11 nt.assert_in = assert_in
11 nt.assert_in = assert_in
12
12
13 def assert_not_in(item, collection):
13 def assert_not_in(item, collection):
14 assert item not in collection, '%r in %r' % (item, collection)
14 assert item not in collection, '%r in %r' % (item, collection)
15
15
16 if not hasattr(nt, 'assert_not_in'):
16 if not hasattr(nt, 'assert_not_in'):
17 nt.assert_not_in = assert_not_in
17 nt.assert_not_in = assert_not_in
18
19 def assert_is_none(obj):
20 assert obj is None, '%r is not None' % obj
21
22 if not hasattr(nt, 'assert_is_none'):
23 nt.assert_is_none = assert_is_none
24
25 def assert_is_not_none(obj):
26 assert obj is not None, '%r is None' % obj
27
28 if not hasattr(nt, 'assert_is_not_none'):
29 nt.assert_is_not_none = assert_is_not_none
General Comments 0
You need to be logged in to leave comments. Login now