Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Move -A only test to extra_tests/
Browse files Browse the repository at this point in the history
  • Loading branch information
rlamy committed Nov 16, 2018
1 parent 7f2f6b5 commit 06c7998
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 47 deletions.
36 changes: 36 additions & 0 deletions extra_tests/test_interpreter.py
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
55 changes: 8 additions & 47 deletions pypy/interpreter/test/test_executioncontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_action_queue(self):
class Action1(executioncontext.AsyncAction):
def perform(self, ec, frame):
events.append('one')

class Action2(executioncontext.AsyncAction):
def perform(self, ec, frame):
events.append('two')
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_fire_inside_perform(self):

class Action1(executioncontext.AsyncAction):
_count = 0

def perform(self, ec, frame):
events.append('one')
if self._count == 0:
Expand Down Expand Up @@ -139,11 +139,11 @@ def perform(self, ec, frame):

def test_llprofile(self):
l = []

def profile_func(space, w_arg, frame, event, w_aarg):
assert w_arg is space.w_None
l.append(event)

space = self.space
space.getexecutioncontext().setllprofile(profile_func, space.w_None)
space.appexec([], """():
Expand All @@ -157,7 +157,7 @@ def test_llprofile_c_call(self):
l = []
seen = []
space = self.space

def profile_func(space, w_arg, frame, event, w_func):
assert w_arg is space.w_None
l.append(event)
Expand Down Expand Up @@ -190,10 +190,10 @@ def check_snippet(snippet, expected_c_call):
check_snippet('max(1, 2, **{})', 'builtin max')
check_snippet('args = (1, 2); max(*args, **{})', 'builtin max')
check_snippet('abs(val=0)', 'builtin abs')

def test_llprofile_c_exception(self):
l = []

def profile_func(space, w_arg, frame, event, w_aarg):
assert w_arg is space.w_None
l.append(event)
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_profile_and_exception(self):
space = self.space
w_res = space.appexec([], """():
l = []
def profile(*args):
l.append(sys.exc_info()[0])
Expand All @@ -327,45 +327,6 @@ def profile(*args):
""")


class AppTestDelNotBlocked:

def setup_method(self, meth):
if not self.runappdirect:
py.test.skip("test is meant for running with py.test -A")
from rpython.tool.udir import udir
tmpfile = udir.join('test_execution_context')
tmpfile.write("""
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()
""")
self.tmpfile = str(tmpfile)
self.w_tmpfile = self.space.wrap(self.tmpfile)

def test_del_not_blocked(self):
# test the behavior fixed in r71420: before, only one __del__
# would be called
import os, sys
print sys.executable, self.tmpfile
if sys.platform == "win32":
cmdformat = '"%s" "%s"'
else:
cmdformat = "'%s' '%s'"
g = os.popen(cmdformat % (sys.executable, self.tmpfile), 'r')
data = g.read()
g.close()
assert 'Called 1' in data
assert 'Called 2' in data


class AppTestProfile:

def test_return(self):
Expand Down

0 comments on commit 06c7998

Please sign in to comment.