Code Duplication    Length = 13-17 lines in 2 locations

tests/misc/AnnotationsTest.py 2 locations

@@ 40-56 (lines=17) @@
37
        with self.assertRaises(ValueError):
38
            function(0)
39
40
    def test_with_custom_type(self):
41
        class Positive:
42
43
            def __init__(self, val):
44
                val = int(val)
45
                if val > 0:
46
                    self.val = val
47
                else:
48
                    raise ValueError
49
50
        function = typechain(Positive, ord)
51
        with self.assertRaises(ValueError):
52
            function(0)
53
        obj = function("10")
54
        self.assertIsInstance(obj, Positive)
55
        self.assertEqual(obj.val, 10)
56
        self.assertEqual(function("0"), 48)
57
58
    def test_with_empty_class(self):
59
        class Dummy:
@@ 19-31 (lines=13) @@
16
            function("str")
17
        self.assertEqual(function("10"), True)
18
19
    def test_with_function(self):
20
        def positive(val):
21
            val = int(val)
22
            if val > 0:
23
                return val
24
            raise ValueError
25
        function = typechain(positive, ord)
26
        with self.assertRaises(ValueError):
27
            function(0)
28
        with self.assertRaises(ValueError):
29
            function("str")
30
        self.assertEqual(function("10"), 10)
31
        self.assertEqual(function("0"), 48)
32
33
    def test_with_function_without_arguments(self):
34
        def dummy():