Code Duplication    Length = 20-20 lines in 2 locations

didyoumean/didyoumean_sugg_tests.py 2 locations

@@ 1675-1694 (lines=20) @@
1672
        """Sometimes, one uses parenthesis instead of brackets."""
1673
        typo, getitem = '(0)', '[0]'
1674
        for ex, sugg in {
1675
            '[0]': "'list[value]'",
1676
            '{0: 0}': "'dict[value]'",
1677
            '"a"': "'str[value]'",
1678
        }.items():
1679
            self.throws(ex + typo, NOTCALLABLE, sugg)
1680
            self.runs(ex + getitem)
1681
        for ex in ['1', 'set()']:
1682
            self.throws(ex + typo, NOTCALLABLE)
1683
1684
    def test_not_callable_custom(self):
1685
        """One must define __call__ to call custom objects."""
1686
        code = 'o = {0}()\no()'
1687
        bad, good = format_str(code, 'CustomClass', 'CallClass')
1688
        sugg = 'implement "__call__" on CustomClass'
1689
        self.throws(bad, NOTCALLABLE, sugg)
1690
        self.runs(good)
1691
1692
    def test_exc_must_derive_from(self):
1693
        """Test when a non-exc object is raised."""
1694
        code = 'raise "ExceptionString"'
1695
        self.throws(code, EXCMUSTDERIVE)
1696
1697
    def test_unordered_builtin(self):
@@ 920-939 (lines=20) @@
917
             "'{0}'".format(sugg2)])
918
        self.runs(bad_sugg)
919
        self.runs(good_sugg)
920
921
    def test_get_on_nondict_cont(self):
922
        """Method get does not exist on all containers."""
923
        code = '{0}().get(0, None)'
924
        dictcode, tuplecode, listcode, setcode = \
925
            format_str(code, 'dict', 'tuple', 'list', 'set')
926
        self.runs(dictcode)
927
        self.throws(setcode, ATTRIBUTEERROR)
928
        for bad_code in tuplecode, listcode:
929
            self.throws(bad_code, ATTRIBUTEERROR,
930
                        "'obj[key]' with a len() check or "
931
                        "try: except: KeyError or IndexError")
932
933
    def test_removed_has_key(self):
934
        """Method has_key is removed from dict."""
935
        code = 'dict().has_key(1)'
936
        new_code = '1 in dict()'
937
        version = (3, 0)
938
        self.runs(code, up_to_version(version))
939
        self.throws(
940
            code,
941
            ATTRIBUTEERROR,
942
            "'key in dict' (has_key is removed)",