Debian Codegraph @

extra_tests/test_interpreter.py

raw symbols SCIP
1 from __future__ import print_function
2 import pytest
3
4 @pytest.fixture
5 def testfile(tmpdir):
6 tmpfile = tmpdir.join('test_execution_context')
7 tmpfile.write("""
8 from __future__ import print_function
9 import gc
10 class X(object):
11 def __del__(self):
12 print("Called", self.num)
13 def f():
14 x1 = X(); x1.num = 1
15 x2 = X(); x2.num = 2
16 x1.next = x2
17 f()
18 gc.collect()
19 gc.collect()
20 """)
21 return tmpfile
22
23
24 def test_del_not_blocked(testfile):
25 # test the behavior fixed in r71420: before, only one __del__
26 # would be called
27 import os, sys
28 if sys.platform == "win32":
29 cmdformat = '"%s" "%s"'
30 else:
31 cmdformat = "'%s' '%s'"
32 g = os.popen(cmdformat % (sys.executable, testfile), 'r')
33 data = g.read()
34 g.close()
35 assert 'Called 1' in data
36 assert 'Called 2' in data