1
|
|
|
if __name__ == '__main__': |
2
|
|
|
import sys |
3
|
|
|
sys.path.insert(0, '..') |
4
|
|
|
sys.path.insert(0, '../..') |
5
|
|
|
|
6
|
|
|
from hamcrest.core.core.isnone import * |
7
|
|
|
|
8
|
|
|
from hamcrest_unit_test.matcher_test import MatcherTest |
9
|
|
|
import unittest |
10
|
|
|
|
11
|
|
|
__author__ = "Jon Reid" |
12
|
|
|
__copyright__ = "Copyright 2011 hamcrest.org" |
13
|
|
|
__license__ = "BSD, see License.txt" |
14
|
|
|
|
15
|
|
|
|
16
|
|
View Code Duplication |
class IsNoneTest(MatcherTest): |
|
|
|
|
17
|
|
|
|
18
|
|
|
def testEvaluatesToTrueIfArgumentIsNone(self): |
19
|
|
|
self.assert_matches('None', none(), None) |
20
|
|
|
|
21
|
|
|
def testEvaluatesToFalseIfArgumentIsNotNone(self): |
22
|
|
|
self.assert_does_not_match('not None', none(), object()) |
23
|
|
|
|
24
|
|
|
def testHasAReadableDescription(self): |
25
|
|
|
self.assert_description('None', none()); |
26
|
|
|
|
27
|
|
|
def testSuccessfulMatchDoesNotGenerateMismatchDescription(self): |
28
|
|
|
self.assert_no_mismatch_description(none(), None) |
29
|
|
|
|
30
|
|
|
def testMismatchDescriptionShowsActualArgument(self): |
31
|
|
|
self.assert_mismatch_description("was 'bad'", none(), 'bad') |
32
|
|
|
|
33
|
|
|
def testDescribeMismatch(self): |
34
|
|
|
self.assert_describe_mismatch("was 'bad'", none(), 'bad') |
35
|
|
|
|
36
|
|
|
|
37
|
|
View Code Duplication |
class NotNoneTest(MatcherTest): |
|
|
|
|
38
|
|
|
|
39
|
|
|
def testEvaluatesToTrueIfArgumentIsNotNone(self): |
40
|
|
|
self.assert_matches('not None', not_none(), object()) |
41
|
|
|
|
42
|
|
|
def testEvaluatesToFalseIfArgumentIsNone(self): |
43
|
|
|
self.assert_does_not_match('None', not_none(), None) |
44
|
|
|
|
45
|
|
|
def testHasAReadableDescription(self): |
46
|
|
|
self.assert_description('not None', not_none()); |
47
|
|
|
|
48
|
|
|
def testSuccessfulMatchDoesNotGenerateMismatchDescription(self): |
49
|
|
|
self.assert_no_mismatch_description(not_none(), 'hi') |
50
|
|
|
|
51
|
|
|
def testMismatchDescriptionShowsActualArgument(self): |
52
|
|
|
self.assert_mismatch_description("was <None>", not_none(), None) |
53
|
|
|
|
54
|
|
|
def testDescribeMismatch(self): |
55
|
|
|
self.assert_describe_mismatch("was <None>", not_none(), None) |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
if __name__ == '__main__': |
59
|
|
|
unittest.main() |
60
|
|
|
|