@@ 1675-1694 (lines=20) @@ | ||
1672 | def test_import_star(self): |
|
1673 | """'import *' in nested functions.""" |
|
1674 | # NICE_TO_HAVE |
|
1675 | codes = [ |
|
1676 | "def func1():\n\tbar='1'\n\tdef func2():" |
|
1677 | "\n\t\tfrom math import *\n\t\tTrue\n\tfunc2()\nfunc1()", |
|
1678 | "def func1():\n\tfrom math import *" |
|
1679 | "\n\tdef func2():\n\t\tTrue", |
|
1680 | ] |
|
1681 | with warnings.catch_warnings(): |
|
1682 | warnings.simplefilter("ignore", category=SyntaxWarning) |
|
1683 | for code in codes: |
|
1684 | self.throws(code, IMPORTSTAR, []) |
|
1685 | ||
1686 | def test_unpack(self): |
|
1687 | """Extended tuple unpacking does not work prior to Python 3.""" |
|
1688 | # NICE_TO_HAVE |
|
1689 | version = (3, 0) |
|
1690 | code = 'a, *b = (1, 2, 3)' |
|
1691 | self.throws(code, INVALIDSYNTAX, [], up_to_version(version)) |
|
1692 | self.runs(code, from_version(version)) |
|
1693 | ||
1694 | def test_unpack2(self): |
|
1695 | """Unpacking in function arguments was supported up to Python 3.""" |
|
1696 | # NICE_TO_HAVE |
|
1697 | version = (3, 0) |
|
@@ 920-939 (lines=20) @@ | ||
917 | """Some methods have been moved from string to str.""" |
|
918 | # NICE_TO_HAVE |
|
919 | version1 = (3, 0) |
|
920 | version2 = (3, 5) |
|
921 | code = 'import string\n{0}.maketrans' |
|
922 | code_str, code_string = format_str(code, 'str', 'string') |
|
923 | code_str2 = 'str.maketrans' # No 'string' import |
|
924 | code_str3 = 'import string as my_string\nstr.maketrans' # Named import |
|
925 | self.throws(code_str, ATTRIBUTEERROR, [], up_to_version(version1)) |
|
926 | self.throws(code_str2, ATTRIBUTEERROR, [], up_to_version(version1)) |
|
927 | self.throws(code_str3, ATTRIBUTEERROR, [], up_to_version(version1)) |
|
928 | self.runs(code_string, up_to_version(version1)) |
|
929 | self.throws(code_string, ATTRIBUTEERROR, [], (version1, version2)) |
|
930 | self.throws(code_string, MODATTRIBUTEERROR, [], from_version(version2)) |
|
931 | self.runs(code_str, from_version(version1)) |
|
932 | self.runs(code_str2, from_version(version1)) |
|
933 | self.runs(code_str3, from_version(version1)) |
|
934 | ||
935 | def test_join(self): |
|
936 | """Test what happens when join is used incorrectly. |
|
937 | ||
938 | This can be frustrating to call join on an iterable instead of a |
|
939 | string. |
|
940 | """ |
|
941 | code = "['a', 'b'].join('-')" |
|
942 | self.throws(code, ATTRIBUTEERROR, "'my_string.join(list)'") |