Code Duplication    Length = 37-37 lines in 2 locations

tests/hamcrest_unit_test/collection/isdict_containingvalue_test.py 1 location

@@ 15-51 (lines=37) @@
12
__license__ = "BSD, see License.txt"
13
14
15
class IsDictContainingValueTest(MatcherTest):
16
17
    def testMatchesSingletonDictionaryContainingValue(self):
18
        dict = {'a': 1}
19
        self.assert_matches('same single value', has_value(equal_to(1)), dict)
20
21
    def testMatchesDictionaryContainingValue(self):
22
        dict = {'a': 1, 'b': 2, 'c': 3}
23
        self.assert_matches('Matches 1', has_value(equal_to(1)), dict)
24
        self.assert_matches('Matches 3', has_value(equal_to(3)), dict)
25
26
    def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
27
        dict = {'a': 1, 'b': 2, 'c': 3}
28
        self.assert_matches('Matches 3', has_value(3), dict)
29
30
    def testDoesNotMatchEmptyDictionary(self):
31
        self.assert_does_not_match('empty', has_value(1), {});
32
33
    def testDoesNotMatchDictionaryMissingValue(self):
34
        dict = {'a': 1, 'b': 2, 'c': 3}
35
        self.assert_does_not_match('no matching value', has_value(4), dict)
36
37
    def testMatchesAnyConformingDictionary(self):
38
        self.assert_matches('quasi-dictionary', has_value('1'), QuasiDictionary())
39
        self.assert_does_not_match('non-dictionary', has_value('1'), object())
40
41
    def testHasReadableDescription(self):
42
        self.assert_description("a dictionary containing value 'a'", has_value('a'))
43
44
    def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
45
        self.assert_no_mismatch_description(has_value(1), {'a': 1})
46
47
    def testMismatchDescriptionShowsActualArgument(self):
48
        self.assert_mismatch_description("was 'bad'", has_value(1), 'bad')
49
50
    def testDescribeMismatch(self):
51
        self.assert_describe_mismatch("was 'bad'", has_value(1), 'bad')
52
53
54
if __name__ == '__main__':

tests/hamcrest_unit_test/collection/isdict_containingkey_test.py 1 location

@@ 15-51 (lines=37) @@
12
__license__ = "BSD, see License.txt"
13
14
15
class IsDictContainingKeyTest(MatcherTest):
16
17
    def testMatchesSingletonDictionaryContainingKey(self):
18
        dict = {'a': 1}
19
        self.assert_matches('same single key', has_key(equal_to('a')), dict)
20
21
    def testMatchesDictionaryContainingKey(self):
22
        dict = {'a': 1, 'b': 2, 'c': 3}
23
        self.assert_matches('Matches a', has_key(equal_to('a')), dict)
24
        self.assert_matches('Matches c', has_key(equal_to('c')), dict)
25
26
    def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
27
        dict = {'a': 1, 'b': 2, 'c': 3}
28
        self.assert_matches('Matches c', has_key('c'), dict)
29
30
    def testDoesNotMatchEmptyDictionary(self):
31
        self.assert_does_not_match('empty', has_key('foo'), {});
32
33
    def testDoesNotMatchDictionaryMissingKey(self):
34
        dict = {'a': 1, 'b': 2, 'c': 3}
35
        self.assert_does_not_match('no matching key', has_key('d'), dict)
36
37
    def testMatchesAnyConformingDictionary(self):
38
        self.assert_matches('quasi-dictionary', has_key(1), QuasiDictionary())
39
        self.assert_does_not_match('non-dictionary', has_key(1), object())
40
41
    def testHasReadableDescription(self):
42
        self.assert_description("a dictionary containing key 'a'", has_key('a'))
43
44
    def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
45
        self.assert_no_mismatch_description(has_key('a'), {'a': 1})
46
47
    def testMismatchDescriptionShowsActualArgument(self):
48
        self.assert_mismatch_description("was 'bad'", has_key('a'), 'bad')
49
50
    def testDescribeMismatch(self):
51
        self.assert_describe_mismatch("was 'bad'", has_key('a'), 'bad')
52
53
54
if __name__ == '__main__':