@@ 1675-1694 (lines=20) @@ | ||
1672 | self.throws(code, INVALIDSYNTAX, [], from_version(version2)) |
|
1673 | self.runs(new_code) |
|
1674 | ||
1675 | def test_old_comparison(self): |
|
1676 | """<> comparison is removed, != always works.""" |
|
1677 | code = '1 {0} 2' |
|
1678 | old, new = '<>', '!=' |
|
1679 | version = (3, 0) |
|
1680 | old_code, new_code = format_str(code, old, new) |
|
1681 | self.runs(old_code, up_to_version(version)) |
|
1682 | self.throws( |
|
1683 | old_code, |
|
1684 | INVALIDCOMP, |
|
1685 | "'!='", |
|
1686 | from_version(version), |
|
1687 | 'pypy') |
|
1688 | self.throws( |
|
1689 | old_code, |
|
1690 | INVALIDSYNTAX, |
|
1691 | "'!='", |
|
1692 | from_version(version), |
|
1693 | 'cython') |
|
1694 | self.runs(new_code) |
|
1695 | ||
1696 | def test_missing_colon(self): |
|
1697 | """Missing colon is a classic mistake.""" |
|
@@ 920-939 (lines=20) @@ | ||
917 | code = func_gen() + 'some_func.{0}' |
|
918 | attributes = [('func_name', '__name__', []), |
|
919 | ('func_doc', '__doc__', []), |
|
920 | ('func_defaults', '__defaults__', ["'__defaults__'"]), |
|
921 | ('func_dict', '__dict__', []), |
|
922 | ('func_closure', '__closure__', []), |
|
923 | ('func_globals', '__globals__', []), |
|
924 | ('func_code', '__code__', [])] |
|
925 | for (old_att, new_att, sugg) in attributes: |
|
926 | old_code, new_code = format_str(code, old_att, new_att) |
|
927 | self.runs(old_code, up_to_version(version)) |
|
928 | self.throws(old_code, ATTRIBUTEERROR, sugg, from_version(version)) |
|
929 | self.runs(new_code) |
|
930 | ||
931 | def test_removed_method_attributes(self): |
|
932 | """Some methods attributes are removed.""" |
|
933 | # NICE_TO_HAVE |
|
934 | version = (3, 0) |
|
935 | code = 'FoobarClass().some_method.{0}' |
|
936 | attributes = [('im_func', '__func__', []), |
|
937 | ('im_self', '__self__', []), |
|
938 | ('im_class', '__self__.__class__', ["'__class__'"])] |
|
939 | for (old_att, new_att, sugg) in attributes: |
|
940 | old_code, new_code = format_str(code, old_att, new_att) |
|
941 | self.runs(old_code, up_to_version(version)) |
|
942 | self.throws(old_code, ATTRIBUTEERROR, sugg, from_version(version)) |