Code Duplication    Length = 20-20 lines in 2 locations

didyoumean/didyoumean_sugg_tests.py 2 locations

@@ 1675-1694 (lines=20) @@
1672
    def test_nonlocal(self):
1673
        """nonlocal keyword is added in Python 3."""
1674
        # NICE_TO_HAVE
1675
        version = (3, 0)
1676
        code = 'def func():\n\tfoo = 1\n\tdef nested():\n\t\tnonlocal foo'
1677
        self.runs(code, from_version(version))
1678
        self.throws(code, INVALIDSYNTAX, [], up_to_version(version))
1679
1680
    def test_nonlocal2(self):
1681
        """nonlocal must be used only when binding exists."""
1682
        # NICE_TO_HAVE
1683
        version = (3, 0)
1684
        code = 'def func():\n\tdef nested():\n\t\tnonlocal foo'
1685
        self.throws(code, NOBINDING, [], from_version(version))
1686
        self.throws(code, INVALIDSYNTAX, [], up_to_version(version))
1687
1688
    def test_nonlocal3(self):
1689
        """nonlocal must be used only when binding to non-global exists."""
1690
        # NICE_TO_HAVE
1691
        version = (3, 0)
1692
        code = 'foo = 1\ndef func():\n\tdef nested():\n\t\tnonlocal foo'
1693
        self.throws(code, NOBINDING, [], from_version(version))
1694
        self.throws(code, INVALIDSYNTAX, [], up_to_version(version))
1695
1696
    def test_octal_literal(self):
1697
        """Syntax for octal liberals has changed."""
@@ 920-939 (lines=20) @@
917
        version = (2, 7)
918
        for method in set(dir(set)) - set(dir(dict)):
919
            if not method.startswith('__'):  # boring suggestions
920
                code = "a = {0}\na." + method
921
                typo, dict1, dict2, sugg, set1 = format_str(
922
                    code, "{}", "dict()", "{0: 0}", "set()", "{0}")
923
                self.throws(typo, ATTRIBUTEERROR)
924
                self.throws(dict1, ATTRIBUTEERROR)
925
                self.throws(dict2, ATTRIBUTEERROR)
926
                self.runs(sugg)
927
                self.throws(set1, INVALIDSYNTAX, [], up_to_version(version))
928
                self.runs(set1, from_version(version))
929
930
    def test_unmatched_msg(self):
931
        """Test that arbitrary strings are supported."""
932
        self.throws(
933
            'raise AttributeError("unmatched ATTRIBUTEERROR")',
934
            UNKNOWN_ATTRIBUTEERROR)
935
936
    # TODO: Add sugg for situation where self/cls is the missing parameter
937
938
939
class TypeErrorTests(GetSuggestionsTests):
940
    """Class for tests related to TypeError."""
941
942
    def test_unhashable(self):