|
@@ 1129-1144 (lines=16) @@
|
| 1126 |
|
self.runs('s = set([tuple()])') |
| 1127 |
|
self.runs('s = set([frozenset()])') |
| 1128 |
|
|
| 1129 |
|
def test_not_sub(self): |
| 1130 |
|
"""Should be function call, not [] operator.""" |
| 1131 |
|
# https://twitter.com/raymondh/status/772957699478663169 |
| 1132 |
|
typo, sugg = '[2]', '(2)' |
| 1133 |
|
code = func_gen(param='a') + 'some_func{0}' |
| 1134 |
|
bad_code, good_code = format_str(code, typo, sugg) |
| 1135 |
|
suggestion = "'function(value)'" |
| 1136 |
|
suggs = ["'__get__'", "'__getattribute__'", suggestion] |
| 1137 |
|
# Only Python 2.7 with cpython has a different error message |
| 1138 |
|
# (leading to more suggestions based on fuzzy matches) |
| 1139 |
|
before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
| 1140 |
|
self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, interpreters='pypy') |
| 1141 |
|
self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, before, 'cython') |
| 1142 |
|
self.throws(bad_code, NOATTRIBUTE_TYPEERROR, suggs, mid, 'cython') |
| 1143 |
|
self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, after, 'cython') |
| 1144 |
|
self.runs(good_code) |
| 1145 |
|
|
| 1146 |
|
def test_method_called_on_class(self): |
| 1147 |
|
"""Test where a method is called on a class and not an instance. |
|
@@ 2127-2138 (lines=12) @@
|
| 2124 |
|
code = '[0] * 999999999999999' |
| 2125 |
|
self.throws(code, MEMORYERROR) |
| 2126 |
|
|
| 2127 |
|
def test_out_of_memory_range(self): |
| 2128 |
|
"""Test what happens in case of MemoryError.""" |
| 2129 |
|
code = '{0}(999999999999999)' |
| 2130 |
|
typo, sugg = 'range', 'xrange' |
| 2131 |
|
bad_code, good_code = format_str(code, typo, sugg) |
| 2132 |
|
before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
| 2133 |
|
self.runs(bad_code, interpreters='pypy') |
| 2134 |
|
self.throws(bad_code, OVERFLOWERR, "'" + sugg + "'", before, 'cython') |
| 2135 |
|
self.throws(bad_code, MEMORYERROR, "'" + sugg + "'", mid, 'cython') |
| 2136 |
|
self.runs(bad_code, after, 'cython') |
| 2137 |
|
self.runs(good_code, before, 'cython') |
| 2138 |
|
self.runs(good_code, mid, 'cython') |
| 2139 |
|
|
| 2140 |
|
|
| 2141 |
|
class ValueErrorTests(GetSuggestionsTests): |