@@ 1229-1244 (lines=16) @@ | ||
1226 | self.runs('s = set([tuple()])') |
|
1227 | self.runs('s = set([frozenset()])') |
|
1228 | ||
1229 | def test_not_sub(self): |
|
1230 | """Should be function call, not [] operator.""" |
|
1231 | # https://twitter.com/raymondh/status/772957699478663169 |
|
1232 | typo, good = '[2]', '(2)' |
|
1233 | code = func_gen(param='a') + 'some_func{0}' |
|
1234 | bad_code, good_code = format_str(code, typo, good) |
|
1235 | suggestion = "'function(value)'" |
|
1236 | suggs = ["'__get__'", "'__getattribute__'", suggestion] |
|
1237 | # Only Python 2.7 with cpython has a different error message |
|
1238 | # (leading to more suggestions based on fuzzy matches) |
|
1239 | before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
|
1240 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, interpreters='pypy') |
|
1241 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, before, 'cpython') |
|
1242 | self.throws(bad_code, NOATTRIBUTE_TYPEERROR, suggs, mid, 'cpython') |
|
1243 | self.throws(bad_code, UNSUBSCRIPTABLE, suggestion, after, 'cpython') |
|
1244 | self.runs(good_code) |
|
1245 | ||
1246 | def test_method_called_on_class(self): |
|
1247 | """Test where a method is called on a class and not an instance. |
|
@@ 2310-2322 (lines=13) @@ | ||
2307 | code = '[0] * 999999999999999' |
|
2308 | self.throws(code, MEMORYERROR) |
|
2309 | ||
2310 | def test_out_of_memory_range(self): |
|
2311 | """Test what happens in case of MemoryError.""" |
|
2312 | code = '{0}(999999999999999)' |
|
2313 | typo, good = 'range', 'xrange' |
|
2314 | sugg = quote(good) |
|
2315 | bad_code, good_code = format_str(code, typo, good) |
|
2316 | before, mid, after = before_mid_and_after((2, 7), (3, 0)) |
|
2317 | self.runs(bad_code, interpreters='pypy') |
|
2318 | self.throws(bad_code, OVERFLOWERR, sugg, before, 'cpython') |
|
2319 | self.throws(bad_code, MEMORYERROR, sugg, mid, 'cpython') |
|
2320 | self.runs(bad_code, after, 'cpython') |
|
2321 | self.runs(good_code, before, 'cpython') |
|
2322 | self.runs(good_code, mid, 'cpython') |
|
2323 | ||
2324 | ||
2325 | class ValueErrorTests(GetSuggestionsTests): |