Completed
Pull Request — master (#70)
by
unknown
01:18
created

tests.hamcrest_unit_test.core.AnyOfTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 0 %
Metric Value
dl 0
loc 67
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A AnyOfTest.testNoMatchIfArgumentFailsToSatisfyEitherOfTwoOtherMatchers() 4 4 1
A AnyOfTest.testHasAReadableDescription() 3 3 1
A AnyOfTest.testMatchesIfArgumentSatisfiesEitherOrBothOfTwoOtherMatchers() 10 10 1
A AnyOfTest.testNoMatchIfArgumentFailsToSatisfyAnyOfManyOtherMatchers() 8 8 1
A AnyOfTest.testMatchesIfArgumentSatisfiesAnyOfManyOtherMatchers() 8 8 1
A AnyOfTest.testProvidesConvenientShortcutForMatchingWithEqualTo() 10 10 1
A AnyOfTest.testMismatchDescriptionDescribesFirstFailingMatch() 5 5 1
A AnyOfTest.testDescribeMismatch() 5 5 1
A AnyOfTest.testSuccessfulMatchDoesNotGenerateMismatchDescription() 4 4 1
1
if __name__ == '__main__':
2
    import sys
3
    sys.path.insert(0, '..')
4
    sys.path.insert(0, '../..')
5
6
from hamcrest.core.core.anyof import *
7
8
from hamcrest.core.core.isequal import equal_to
9
from hamcrest_unit_test.matcher_test import MatcherTest
10
import unittest
11
12
__author__ = "Jon Reid"
13
__copyright__ = "Copyright 2011 hamcrest.org"
14
__license__ = "BSD, see License.txt"
15
16
17 View Code Duplication
class AnyOfTest(MatcherTest):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
18
19
    def testMatchesIfArgumentSatisfiesEitherOrBothOfTwoOtherMatchers(self):
20
        self.assert_matches('first matcher',
21
                            any_of(equal_to('good'), equal_to('bad')),
22
                            'good')
23
        self.assert_matches('second matcher',
24
                            any_of(equal_to('bad'), equal_to('good')),
25
                            'good')
26
        self.assert_matches('both matchers',
27
                            any_of(equal_to('good'), equal_to('good')),
28
                            'good')
29
30
    def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
31
        self.assert_matches('first matcher',
32
                            any_of('good', 'bad'),
33
                            'good')
34
        self.assert_matches('second matcher',
35
                            any_of('bad', 'good'),
36
                            'good')
37
        self.assert_matches('both matchers',
38
                            any_of('good', 'good'),
39
                            'good')
40
41
    def testNoMatchIfArgumentFailsToSatisfyEitherOfTwoOtherMatchers(self):
42
        self.assert_does_not_match('either matcher',
43
                                   any_of(equal_to('bad'), equal_to('bad')),
44
                                   'good')
45
46
    def testMatchesIfArgumentSatisfiesAnyOfManyOtherMatchers(self):
47
        self.assert_matches('matcher in the middle',
48
                            any_of(equal_to('bad'),
49
                                   equal_to('bad'),
50
                                   equal_to('good'),
51
                                   equal_to('bad'),
52
                                   equal_to('bad')),
53
                            'good')
54
55
    def testNoMatchIfArgumentFailsToSatisfyAnyOfManyOtherMatchers(self):
56
        self.assert_does_not_match('all matchers',
57
                                   any_of(equal_to('bad'),
58
                                          equal_to('bad'),
59
                                          equal_to('bad'),
60
                                          equal_to('bad'),
61
                                          equal_to('bad')),
62
                                  'good')
63
64
    def testHasAReadableDescription(self):
65
        self.assert_description("('good' or 'bad' or 'ugly')",
66
                    any_of(equal_to('good'), equal_to('bad'), equal_to('ugly')))
67
68
    def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
69
        self.assert_no_mismatch_description(
70
                                any_of(equal_to('good'), equal_to('bad')),
71
                                'good')
72
73
    def testMismatchDescriptionDescribesFirstFailingMatch(self):
74
        self.assert_mismatch_description(
75
                                "was 'ugly'",
76
                                any_of(equal_to('bad'), equal_to('good')),
77
                                'ugly')
78
79
    def testDescribeMismatch(self):
80
        self.assert_describe_mismatch(
81
                                "was 'ugly'",
82
                                any_of(equal_to('bad'), equal_to('good')),
83
                                'ugly')
84
85
86
if __name__ == '__main__':
87
    unittest.main()
88