Code Duplication    Length = 11-13 lines in 2 locations

port_range/tests/test_port_range.py 2 locations

@@ 65-77 (lines=13) @@
62
63
        # Single port.
64
        self.assertEqual(PortRange('42', strict=True).bounds, (42, 42))
65
        self.assertEqual(PortRange(42, strict=True).bounds, (42, 42))
66
        self.assertEqual(PortRange([42], strict=True).bounds, (42, 42))
67
        self.assertEqual(PortRange(['42'], strict=True).bounds, (42, 42))
68
69
        # Reversed order.
70
        self.assertRaises(ValueError, PortRange, [4242, 42], True)
71
        self.assertRaises(ValueError, PortRange, '4242-42', True)
72
        self.assertRaises(ValueError, PortRange, (4242, 42), True)
73
        self.assertRaises(ValueError, PortRange, ('4242', '42'), True)
74
        # Casting a set to a list might ends up with a naturally sorted list.
75
        # self.assertRaises(ValueError, PortRange, set([4242, 42]), True)
76
        # self.assertRaises(ValueError, PortRange, set(['4242', '42']), True)
77
78
        # Invalid types and length.
79
        self.assertRaises(ValueError, PortRange, [None, 42], True)
80
        self.assertRaises(ValueError, PortRange, [42, None], True)
@@ 53-63 (lines=11) @@
50
        self.assertRaises(ValueError, PortRange, [42, None])
51
        self.assertRaises(ValueError, PortRange, [42, 32, 3])
52
        self.assertRaises(ValueError, PortRange, [42, None, 32, 3, -4])
53
54
    def test_strict_range_parsing(self):
55
        # Normal range.
56
        self.assertEqual(
57
            PortRange('42-4242', strict=True).bounds, (42, 4242))
58
        self.assertEqual(
59
            PortRange([42, 4242], strict=True).bounds, (42, 4242))
60
        self.assertEqual(
61
            PortRange(['42', '4242'], strict=True).bounds, (42, 4242))
62
63
        # Single port.
64
        self.assertEqual(PortRange('42', strict=True).bounds, (42, 42))
65
        self.assertEqual(PortRange(42, strict=True).bounds, (42, 42))
66
        self.assertEqual(PortRange([42], strict=True).bounds, (42, 42))