@@ 1675-1694 (lines=20) @@ | ||
1672 | code = '[0] * 999999999999999' |
|
1673 | self.throws(code, MEMORYERROR) |
|
1674 | ||
1675 | def test_out_of_memory_range(self): |
|
1676 | """Test what happens in case of MemoryError.""" |
|
1677 | code = '{0}(999999999999999)' |
|
1678 | typo, sugg = 'range', 'xrange' |
|
1679 | bad_code, good_code = format_str(code, typo, sugg) |
|
1680 | self.runs(bad_code, ALL_VERSIONS, 'pypy') |
|
1681 | version = (2, 7) |
|
1682 | version2 = (3, 0) |
|
1683 | self.throws( |
|
1684 | bad_code, |
|
1685 | OVERFLOWERR, "'" + sugg + "'", |
|
1686 | up_to_version(version), |
|
1687 | 'cython') |
|
1688 | self.throws( |
|
1689 | bad_code, |
|
1690 | MEMORYERROR, "'" + sugg + "'", |
|
1691 | (version, version2), |
|
1692 | 'cython') |
|
1693 | self.runs(good_code, up_to_version(version2), 'cython') |
|
1694 | self.runs(bad_code, from_version(version2), 'cython') |
|
1695 | ||
1696 | ||
1697 | class ValueErrorTests(GetSuggestionsTests): |
|
@@ 920-939 (lines=20) @@ | ||
917 | """Test that other errors do not crash.""" |
|
918 | self.throws('dict()[list()] = 1', UNHASHABLE) |
|
919 | ||
920 | def test_not_sub(self): |
|
921 | """Should be function call, not [] operator.""" |
|
922 | typo, sugg = '[2]', '(2)' |
|
923 | code = func_gen(param='a') + 'some_func{0}' |
|
924 | bad_code, good_code = format_str(code, typo, sugg) |
|
925 | suggestion = "'function(value)'" |
|
926 | # Only Python 2.7 with cpython has a different error message |
|
927 | # (leading to more suggestions based on fuzzy matches) |
|
928 | version1 = (2, 7) |
|
929 | version2 = (3, 0) |
|
930 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, |
|
931 | ALL_VERSIONS, 'pypy') |
|
932 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, |
|
933 | up_to_version(version1), 'cython') |
|
934 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, |
|
935 | from_version(version2), 'cython') |
|
936 | self.throws(bad_code, NOATTRIBUTE_TYPEERROR, |
|
937 | ["'__get__'", "'__getattribute__'", suggestion], |
|
938 | (version1, version2), 'cython') |
|
939 | self.runs(good_code) |
|
940 | ||
941 | def test_method_called_on_class(self): |
|
942 | """Test where a method is called on a class and not an instance. |