Code Duplication    Length = 20-20 lines in 2 locations

didyoumean/didyoumean_sugg_tests.py 2 locations

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