|
@@ 1190-1205 (lines=16) @@
|
| 1187 |
|
self.runs('s = set([tuple()])') |
| 1188 |
|
self.runs('s = set([frozenset()])') |
| 1189 |
|
|
| 1190 |
|
def test_not_sub(self): |
| 1191 |
|
"""Should be function call, not [] operator.""" |
| 1192 |
|
# https://twitter.com/raymondh/status/772957699478663169 |
| 1193 |
|
typo, good = '[2]', '(2)' |
| 1194 |
|
code = func_gen(param='a') + 'some_func{0}' |
| 1195 |
|
bad_code, good_code = format_str(code, typo, good) |
| 1196 |
|
suggestion = "'function(value)'" |
| 1197 |
|
suggs = ["'__get__'", "'__getattribute__'", suggestion] |
| 1198 |
|
# Only Python 2.7 with cpython has a different error message |
| 1199 |
|
# (leading to more suggestions based on fuzzy matches) |
| 1200 |
|
before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
| 1201 |
|
self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, interpreters='pypy') |
| 1202 |
|
self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, before, 'cpython') |
| 1203 |
|
self.throws(bad_code, NOATTRIBUTE_TYPEERROR, suggs, mid, 'cpython') |
| 1204 |
|
self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, after, 'cpython') |
| 1205 |
|
self.runs(good_code) |
| 1206 |
|
|
| 1207 |
|
def test_method_called_on_class(self): |
| 1208 |
|
"""Test where a method is called on a class and not an instance. |
|
@@ 2271-2283 (lines=13) @@
|
| 2268 |
|
code = '[0] * 999999999999999' |
| 2269 |
|
self.throws(code, MEMORYERROR) |
| 2270 |
|
|
| 2271 |
|
def test_out_of_memory_range(self): |
| 2272 |
|
"""Test what happens in case of MemoryError.""" |
| 2273 |
|
code = '{0}(999999999999999)' |
| 2274 |
|
typo, good = 'range', 'xrange' |
| 2275 |
|
sugg = quote(good) |
| 2276 |
|
bad_code, good_code = format_str(code, typo, good) |
| 2277 |
|
before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
| 2278 |
|
self.runs(bad_code, interpreters='pypy') |
| 2279 |
|
self.throws(bad_code, OVERFLOWERR, sugg, before, 'cpython') |
| 2280 |
|
self.throws(bad_code, MEMORYERROR, sugg, mid, 'cpython') |
| 2281 |
|
self.runs(bad_code, after, 'cpython') |
| 2282 |
|
self.runs(good_code, before, 'cpython') |
| 2283 |
|
self.runs(good_code, mid, 'cpython') |
| 2284 |
|
|
| 2285 |
|
|
| 2286 |
|
class ValueErrorTests(GetSuggestionsTests): |