Code Duplication    Length = 25-39 lines in 2 locations

tests/hamcrest_unit_test/object/hasproperty_test.py 1 location

@@ 85-123 (lines=39) @@
82
                                       matcher,
83
                                       target_class())
84
85
class HasPropertyTest(MatcherTest, ObjectPropertyMatcher):
86
87
    def testHasPropertyWithoutValueMatcher(self):
88
        self.assert_matches_for_all_types('has property with name',
89
                                          has_property('field'))
90
91
    def testHasPropertyWithoutValueMatcherNegative(self):
92
        self.assert_does_not_match_for_all_types('has property with name',
93
                                                 has_property('not_there'))
94
95
    def testHasPropertyWithValueMatcher(self):
96
        self.assert_matches_for_all_types('has property with name and value',
97
                                          has_property('field', 'value'))
98
99
    def testHasPropertyWithValueMatcherNegative(self):
100
        self.assert_does_not_match_for_all_types('has property with name',
101
                                                 has_property('field', 'not the value'))
102
103
    def testDescription(self):
104
        self.assert_description("an object with a property 'field' matching ANYTHING",
105
                                has_property('field'))
106
        self.assert_description("an object with a property 'field' matching 'value'",
107
                                has_property('field', 'value'))
108
109
    def testDescribeMissingProperty(self):
110
        self.assert_mismatch_description("<OnePropertyNewStyle> did not have the 'not_there' property",
111
                                         has_property('not_there'), OnePropertyNewStyle())
112
113
    def testDescribePropertyValueMismatch(self):
114
        self.assert_mismatch_description("property 'field' was 'value'",
115
                                         has_property('field', 'another_value'), OnePropertyNewStyle())
116
117
    def testMismatchDescription(self):
118
        self.assert_describe_mismatch("<OnePropertyNewStyle> did not have the 'not_there' property",
119
                                      has_property('not_there'),
120
                                      OnePropertyNewStyle())
121
122
    def testNoMismatchDescriptionOnMatch(self):
123
        self.assert_no_mismatch_description(has_property('field', 'value'), OnePropertyNewStyle())
124
125
126
class HasPropertiesTest(MatcherTest, ObjectPropertyMatcher):

tests/hamcrest_unit_test/core/isnot_test.py 1 location

@@ 17-41 (lines=25) @@
14
__license__ = "BSD, see License.txt"
15
16
17
class IsNotTest(MatcherTest):
18
19
    def testEvaluatesToTheTheLogicalNegationOfAnotherMatcher(self):
20
        self.assert_matches('invert mismatch', is_not(equal_to('A')), 'B')
21
        self.assert_does_not_match('invert match', is_not(equal_to('A')), 'A')
22
23
    def testProvidesConvenientShortcutForNotEqualTo(self):
24
        self.assert_matches('invert mismatch', is_not('A'), 'B');
25
        self.assert_does_not_match('invert match', is_not('A'), 'A');
26
27
    def testProvidesConvenientShortcutForNotInstanceOf(self):
28
        self.assert_matches('invert mismatch', is_not(str), 1);
29
        self.assert_does_not_match('invert match', is_not(str), 'A');
30
31
    def testHasAReadableDescription(self):
32
        self.assert_description("not 'A'", is_not('A'));
33
34
    def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
35
        self.assert_no_mismatch_description(is_not('A'), 'B')
36
37
    def testMismatchDescriptionShowsActualArgument(self):
38
        self.assert_mismatch_description("was 'A'", is_not('A'), 'A')
39
40
    def testDescribeMismatch(self):
41
        self.assert_describe_mismatch("was 'A'", is_not('A'), 'A')
42
43
44
if __name__ == '__main__':