@@ 1219-1234 (lines=16) @@ | ||
1216 | self.runs('s = set([tuple()])') |
|
1217 | self.runs('s = set([frozenset()])') |
|
1218 | ||
1219 | def test_not_sub(self): |
|
1220 | """Should be function call, not [] operator.""" |
|
1221 | # https://twitter.com/raymondh/status/772957699478663169 |
|
1222 | typo, good = '[2]', '(2)' |
|
1223 | code = func_gen(param='a') + 'some_func{0}' |
|
1224 | bad_code, good_code = format_str(code, typo, good) |
|
1225 | suggestion = "'function(value)'" |
|
1226 | suggs = ["'__get__'", "'__getattribute__'", suggestion] |
|
1227 | # Only Python 2.7 with cpython has a different error message |
|
1228 | # (leading to more suggestions based on fuzzy matches) |
|
1229 | before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
|
1230 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, interpreters='pypy') |
|
1231 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, before, 'cpython') |
|
1232 | self.throws(bad_code, NOATTRIBUTE_TYPEERROR, suggs, mid, 'cpython') |
|
1233 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, after, 'cpython') |
|
1234 | self.runs(good_code) |
|
1235 | ||
1236 | def test_method_called_on_class(self): |
|
1237 | """Test where a method is called on a class and not an instance. |
|
@@ 2300-2312 (lines=13) @@ | ||
2297 | code = '[0] * 999999999999999' |
|
2298 | self.throws(code, MEMORYERROR) |
|
2299 | ||
2300 | def test_out_of_memory_range(self): |
|
2301 | """Test what happens in case of MemoryError.""" |
|
2302 | code = '{0}(999999999999999)' |
|
2303 | typo, good = 'range', 'xrange' |
|
2304 | sugg = quote(good) |
|
2305 | bad_code, good_code = format_str(code, typo, good) |
|
2306 | before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
|
2307 | self.runs(bad_code, interpreters='pypy') |
|
2308 | self.throws(bad_code, OVERFLOWERR, sugg, before, 'cpython') |
|
2309 | self.throws(bad_code, MEMORYERROR, sugg, mid, 'cpython') |
|
2310 | self.runs(bad_code, after, 'cpython') |
|
2311 | self.runs(good_code, before, 'cpython') |
|
2312 | self.runs(good_code, mid, 'cpython') |
|
2313 | ||
2314 | ||
2315 | class ValueErrorTests(GetSuggestionsTests): |