Code Duplication    Length = 17-23 lines in 2 locations

didyoumean/didyoumean_sugg_tests.py 2 locations

@@ 1042-1064 (lines=23) @@
1039
        self.runs(code_str2, from_version(version1))
1040
        self.runs(code_str3, from_version(version1))
1041
1042
    def test_moved_between_imp_importlib(self):
1043
        """Some methods have been moved from imp to importlib."""
1044
        # NICE_TO_HAVE
1045
        # reload removed from Python 3
1046
        # importlib module new in Python 2.7
1047
        # importlib.reload new in Python 3.4
1048
        # imp.reload new in Python 3.2
1049
        version27 = (2, 7)
1050
        version3 = (3, 0)
1051
        version26 = up_to_version(version27)
1052
        code = '{0}reload(math)'
1053
        null, code_imp, code_importlib = format_str(
1054
            code, '', 'import imp\nimp.', 'import importlib\nimportlib.')
1055
        self.runs(null, up_to_version(version3))
1056
        self.throws(null, NAMEERROR,
1057
                    RELOAD_REMOVED_MSG, from_version(version3))
1058
        self.runs(code_imp)
1059
        self.throws(code_importlib, NOMODULE, [], version26)
1060
        self.throws(code_importlib, ATTRIBUTEERROR,
1061
                    "'reload(module)'", (version27, version3))
1062
        self.throws(code_importlib, ATTRIBUTEERROR,
1063
                    [], (version3, (3, 4)))
1064
        self.runs(code_importlib, from_version((3, 4)))
1065
1066
    def test_join(self):
1067
        """Test what happens when join is used incorrectly.
@@ 1473-1489 (lines=17) @@
1470
            self.throws(bad_code, INTEXPECTED, [], up_to_version(v3))
1471
            self.throws(bad_code, CANNOTBEINTERPRETED, [], from_version(v3))
1472
1473
    def test_float_cannot_be_interpreted_as_int(self):
1474
        """Use float instead of int."""
1475
        # NICE_TO_HAVE
1476
        v27 = (2, 7)
1477
        v3 = (3, 0)
1478
        for code in self.RANGE_CODE_TEMPLATES:
1479
            full_code = 'import math\n' + code
1480
            good1, good2, bad = format_str(
1481
                full_code, 'int(12.0)', 'math.floor(12.0)', '12.0')
1482
            self.runs(good1)
1483
            self.runs(good2, up_to_version(v27))
1484
            # floor returns a float before Python 3 -_-
1485
            self.throws(good2, INTEXPECTED, [], (v27, v3))
1486
            self.runs(good2, from_version(v3))
1487
            self.runs(bad, up_to_version(v27))
1488
            self.throws(bad, INTEXPECTED, [], (v27, v3))
1489
            self.throws(bad, CANNOTBEINTERPRETED, [], from_version(v3))
1490
1491
    def test_customclass_cannot_be_interpreter_as_int(self):
1492
        """Forget to implement the __index__ method."""