|
18 | 18 |
|
19 | 19 | import functools |
20 | 20 | import os |
| 21 | +import platform |
21 | 22 | from os.path import join as pjoin |
22 | 23 | import random |
23 | 24 | import string |
@@ -158,7 +159,7 @@ def doctest_reset_del(): |
158 | 159 |
|
159 | 160 | In [3]: a = A() |
160 | 161 |
|
161 | | - In [4]: get_ipython().reset() |
| 162 | + In [4]: get_ipython().reset(); import gc; x = gc.collect(0) |
162 | 163 | Hi |
163 | 164 |
|
164 | 165 | In [5]: 1+1 |
@@ -241,6 +242,10 @@ def test_simpledef(self): |
241 | 242 | _ip.run_cell("t = isinstance(f(), foo)") |
242 | 243 | assert _ip.user_ns["t"] is True |
243 | 244 |
|
| 245 | + @pytest.mark.xfail( |
| 246 | + platform.python_implementation() == "PyPy", |
| 247 | + reason="expecting __del__ call on exit is unreliable and doesn't happen on PyPy", |
| 248 | + ) |
244 | 249 | def test_obj_del(self): |
245 | 250 | """Test that object's __del__ methods are called on exit.""" |
246 | 251 | src = ("class A(object):\n" |
@@ -286,14 +291,20 @@ def test_run_second(self): |
286 | 291 | _ip.magic("run %s" % empty.fname) |
287 | 292 | assert _ip.user_ns["afunc"]() == 1 |
288 | 293 |
|
289 | | - @dec.skip_win32 |
290 | 294 | def test_tclass(self): |
291 | 295 | mydir = os.path.dirname(__file__) |
292 | | - tc = os.path.join(mydir, 'tclass') |
293 | | - src = ("%%run '%s' C-first\n" |
294 | | - "%%run '%s' C-second\n" |
295 | | - "%%run '%s' C-third\n") % (tc, tc, tc) |
296 | | - self.mktmp(src, '.ipy') |
| 296 | + tc = os.path.join(mydir, "tclass") |
| 297 | + src = f"""\ |
| 298 | +import gc |
| 299 | +%run "{tc}" C-first |
| 300 | +gc.collect(0) |
| 301 | +%run "{tc}" C-second |
| 302 | +gc.collect(0) |
| 303 | +%run "{tc}" C-third |
| 304 | +gc.collect(0) |
| 305 | +%reset -f |
| 306 | +""" |
| 307 | + self.mktmp(src, ".ipy") |
297 | 308 | out = """\ |
298 | 309 | ARGV 1-: ['C-first'] |
299 | 310 | ARGV 1-: ['C-second'] |
|
0 commit comments