@@ 1356-1372 (lines=17) @@ | ||
1353 | code = 'class MyClass:\n\tdef func(self, ' + sugg + '):' \ |
|
1354 | '\n\t\tpass\nMyClass().func({0}=1)' |
|
1355 | bad_code, good_code = format_str(code, typo, sugg) |
|
1356 | self.throws(bad_code, UNEXPECTEDKWARG, "'" + sugg + "'") |
|
1357 | self.runs(good_code) |
|
1358 | ||
1359 | def test_keyword_arg_class_method(self): |
|
1360 | """Should be the same as previous test but on a class method.""" |
|
1361 | code = 'class MyClass:\n\t@classmethod\n\tdef func(cls, a):' \ |
|
1362 | '\n\t\tpass\nMyClass.func({0}=1)' |
|
1363 | bad_code, good_code = format_str(code, 'babar', 'a') |
|
1364 | self.throws(bad_code, UNEXPECTEDKWARG) |
|
1365 | self.runs(good_code) |
|
1366 | ||
1367 | def test_keyword_arg_class_method2(self): |
|
1368 | """Should be the same as previous test but on a class method.""" |
|
1369 | typo, sugg = 'abcdf', 'abcdef' |
|
1370 | code = 'class MyClass:\n\t@classmethod ' \ |
|
1371 | '\n\tdef func(cls, ' + sugg + '):\n ' \ |
|
1372 | '\t\tpass\nMyClass.func({0}=1)' |
|
1373 | bad_code, good_code = format_str(code, typo, sugg) |
|
1374 | self.throws(bad_code, UNEXPECTEDKWARG, "'" + sugg + "'") |
|
1375 | self.runs(good_code) |
|
@@ 1808-1818 (lines=11) @@ | ||
1805 | def test_no_name_no_sugg(self): |
|
1806 | """No suggestion.""" |
|
1807 | self.throws('from math import fsfsdfdjlkf', CANNOTIMPORT) |
|
1808 | ||
1809 | def test_wrong_import(self): |
|
1810 | """Should be 'math'.""" |
|
1811 | code = 'from {0} import pi' |
|
1812 | typo, sugg = 'itertools', 'math' |
|
1813 | self.assertTrue(sugg in STAND_MODULES) |
|
1814 | bad_code, good_code = format_str(code, typo, sugg) |
|
1815 | self.throws(bad_code, CANNOTIMPORT, "'" + good_code + "'") |
|
1816 | self.runs(good_code) |
|
1817 | ||
1818 | def test_typo_in_method(self): |
|
1819 | """Should be 'pi'.""" |
|
1820 | code = 'from math import {0}' |
|
1821 | typo, sugg = 'pie', 'pi' |