|
@@ 1675-1694 (lines=20) @@
|
| 1672 |
|
version = (3, 0) |
| 1673 |
|
version2 = (3, 4) |
| 1674 |
|
self.runs(code, up_to_version(version)) |
| 1675 |
|
self.throws(code, INVALIDSYNTAX, [], (version, version2)) |
| 1676 |
|
self.throws(code, INVALIDSYNTAX, [], from_version(version2)) |
| 1677 |
|
self.runs(new_code) |
| 1678 |
|
|
| 1679 |
|
def test_exec(self): |
| 1680 |
|
"""exec is a functions now and needs parenthesis.""" |
| 1681 |
|
# NICE_TO_HAVE |
| 1682 |
|
code, new_code = 'exec "1"', 'exec("1")' |
| 1683 |
|
version = (3, 0) |
| 1684 |
|
version2 = (3, 4) |
| 1685 |
|
self.runs(code, up_to_version(version)) |
| 1686 |
|
self.throws(code, INVALIDSYNTAX, [], (version, version2)) |
| 1687 |
|
self.throws(code, INVALIDSYNTAX, [], from_version(version2)) |
| 1688 |
|
self.runs(new_code) |
| 1689 |
|
|
| 1690 |
|
def test_old_comparison(self): |
| 1691 |
|
"""<> comparison is removed, != always works.""" |
| 1692 |
|
code = '1 {0} 2' |
| 1693 |
|
old, new = '<>', '!=' |
| 1694 |
|
version = (3, 0) |
| 1695 |
|
old_code, new_code = format_str(code, old, new) |
| 1696 |
|
self.runs(old_code, up_to_version(version)) |
| 1697 |
|
self.throws( |
|
@@ 920-939 (lines=20) @@
|
| 917 |
|
old_code, new_code1, new_code2 = format_str(code, old, sugg1, sugg2) |
| 918 |
|
version = (3, 0) |
| 919 |
|
self.runs(old_code, up_to_version(version)) |
| 920 |
|
self.throws( |
| 921 |
|
old_code, |
| 922 |
|
ATTRIBUTEERROR, |
| 923 |
|
["'" + sugg1 + "'", "'" + sugg2 + "'", "'writelines'"], |
| 924 |
|
from_version(version)) |
| 925 |
|
self.runs(new_code1) |
| 926 |
|
self.runs(new_code2) |
| 927 |
|
|
| 928 |
|
def test_removed_function_attributes(self): |
| 929 |
|
"""Some functions attributes are removed.""" |
| 930 |
|
# NICE_TO_HAVE |
| 931 |
|
version = (3, 0) |
| 932 |
|
code = func_gen() + 'some_func.{0}' |
| 933 |
|
attributes = [('func_name', '__name__', []), |
| 934 |
|
('func_doc', '__doc__', []), |
| 935 |
|
('func_defaults', '__defaults__', ["'__defaults__'"]), |
| 936 |
|
('func_dict', '__dict__', []), |
| 937 |
|
('func_closure', '__closure__', []), |
| 938 |
|
('func_globals', '__globals__', []), |
| 939 |
|
('func_code', '__code__', [])] |
| 940 |
|
for (old_att, new_att, sugg) in attributes: |
| 941 |
|
old_code, new_code = format_str(code, old_att, new_att) |
| 942 |
|
self.runs(old_code, up_to_version(version)) |