Code Duplication    Length = 15-27 lines in 2 locations

didyoumean/didyoumean_sugg_tests.py 2 locations

@@ 1301-1327 (lines=27) @@
1298
    def test_keyword_arg_other_objects_with_name(self):
1299
        """Mix of previous tests but with more objects defined.
1300
1301
        Non-function object with same same as the function tested are defined
1302
        to ensure that things do work fine.
1303
        """
1304
        code = 'func = "not_a_func"\nclass MyClass:\n\tdef func(self, a):' \
1305
               '\n\t\tpass\nMyClass().func({0}=1)'
1306
        bad_code, good_code = format_str(code, 'babar', 'a')
1307
        self.throws(bad_code, UNEXPECTEDKWARG)
1308
        self.runs(good_code)
1309
1310
    def test_keyword_builtin(self):
1311
        """A few builtins (like int()) have a different error message."""
1312
        # NICE_TO_HAVE
1313
        # 'max', 'input', 'len', 'abs', 'all', etc have a specific error
1314
        # message and are not relevant here
1315
        for builtin in ['int', 'float', 'bool', 'complex']:
1316
            code = builtin + '(this_doesnt_exist=2)'
1317
            self.throws(code, UNEXPECTEDKWARG2, [], ALL_VERSIONS, 'cython')
1318
            self.throws(code, UNEXPECTEDKWARG, [], ALL_VERSIONS, 'pypy')
1319
1320
    def test_keyword_builtin_print(self):
1321
        """Builtin "print" has a different error message."""
1322
        # It would be NICE_TO_HAVE suggestions on keyword arguments
1323
        v3 = (3, 0)
1324
        code = "c = 'string'\nb = print(c, end_='toto')"
1325
        self.throws(code, INVALIDSYNTAX, [], up_to_version(v3))
1326
        self.throws(code, UNEXPECTEDKWARG2, [], from_version(v3), 'cython')
1327
        self.throws(code, UNEXPECTEDKWARG3, [], from_version(v3), 'pypy')
1328
1329
    def test_no_implicit_str_conv(self):
1330
        """Trying to concatenate a non-string value to a string."""
@@ 897-911 (lines=15) @@
894
        self.runs(new_code1)
895
        self.runs(new_code2)
896
897
    def test_removed_function_attributes(self):
898
        """Some functions attributes are removed."""
899
        # NICE_TO_HAVE
900
        version = (3, 0)
901
        code = func_gen() + 'some_func.{0}'
902
        attributes = [('func_name', '__name__', []),
903
                      ('func_doc', '__doc__', []),
904
                      ('func_defaults', '__defaults__', ["'__defaults__'"]),
905
                      ('func_dict', '__dict__', []),
906
                      ('func_closure', '__closure__', []),
907
                      ('func_globals', '__globals__', []),
908
                      ('func_code', '__code__', [])]
909
        for (old_att, new_att, sugg) in attributes:
910
            old_code, new_code = format_str(code, old_att, new_att)
911
            self.runs(old_code, up_to_version(version))
912
            self.throws(old_code, ATTRIBUTEERROR, sugg, from_version(version))
913
            self.runs(new_code)
914