This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import print_function | ||
import pytest | ||
|
||
@pytest.fixture | ||
def testfile(tmpdir): | ||
tmpfile = tmpdir.join('test_execution_context') | ||
tmpfile.write(""" | ||
from __future__ import print_function | ||
import gc | ||
class X(object): | ||
def __del__(self): | ||
print("Called", self.num) | ||
def f(): | ||
x1 = X(); x1.num = 1 | ||
x2 = X(); x2.num = 2 | ||
x1.next = x2 | ||
f() | ||
gc.collect() | ||
gc.collect() | ||
""") | ||
return tmpfile | ||
|
||
|
||
def test_del_not_blocked(testfile): | ||
# test the behavior fixed in r71420: before, only one __del__ | ||
# would be called | ||
import os, sys | ||
if sys.platform == "win32": | ||
cmdformat = '"%s" "%s"' | ||
else: | ||
cmdformat = "'%s' '%s'" | ||
g = os.popen(cmdformat % (sys.executable, testfile), 'r') | ||
data = g.read() | ||
g.close() | ||
assert 'Called 1' in data | ||
assert 'Called 2' in data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters