[pypy-svn] r41259 - in pypy/dist/pypy/lib: app_test test2
hpk at codespeak.net
hpk at codespeak.net
Sat Mar 24 20:58:24 CET 2007
Author: hpk
Date: Sat Mar 24 20:58:23 2007
New Revision: 41259
Added:
pypy/dist/pypy/lib/test2/sample_aop_code.py
- copied, changed from r41258, pypy/dist/pypy/lib/app_test/sample_aop_code.py
Removed:
pypy/dist/pypy/lib/app_test/sample_aop_code.py
Modified:
pypy/dist/pypy/lib/test2/test_aop.py
Log:
moving sample_aop_code to test2
and reverting 41253 because importing
the py lib with aop global tweaking around
breaks. Trying now with teardown_module to
cleanup any leftover generated modules
because i don't want to change much within
the aop test code.
Modified: pypy/dist/pypy/lib/test2/test_aop.py
==============================================================================
--- pypy/dist/pypy/lib/test2/test_aop.py (original)
+++ pypy/dist/pypy/lib/test2/test_aop.py Sat Mar 24 20:58:23 2007
@@ -1,7 +1,12 @@
import py
from pypy.conftest import option, maketestobjspace
-
+def teardown_module(mod):
+ mydir = py.magic.autopath().dirpath()
+ for p in mydir.listdir():
+ if p.purebasename.startswith("aop_"):
+ p.remove()
+
class BaseAppTest(object):
def setup_class(cls):
if option.runappdirect:
@@ -160,8 +165,9 @@
class AppTestWeavingAtExecution(BaseAppTest):
def test_simple_aspect_before_execution(self):
from aop import PointCut, Aspect, before
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_before_execution')
class AspectTest:
__metaclass__ = Aspect
@@ -178,19 +184,20 @@
assert __aop__.advices == [(aspect, AspectTest.advice_before_execution)]
assert not aspect.executed
- aop_before_execution = sample_aop_code.import_('aop_before_execution')
-
+ import aop_before_execution
assert aspect.executed == 0
answ = aop_before_execution.foo(1,2)
assert aspect.executed == 1
assert aspect.argnames == ['b', 'c']
assert aspect.flags == 0
assert answ == 47
+ sample_aop_code.clean_module('aop_before_execution')
def test_aspect_before_meth_execution(self):
from aop import PointCut, Aspect, before
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_before_meth_execution')
class AspectTest:
__metaclass__ = Aspect
@@ -207,19 +214,20 @@
assert __aop__.advices == [(aspect, AspectTest.advice_before_meth_execution)]
assert not aspect.executed
- aop_before_meth_execution = sample_aop_code.import_(
- 'aop_before_meth_execution')
+ import aop_before_meth_execution
assert aspect.executed == 0
answ = aop_before_meth_execution.truc()
assert aspect.executed == 1
assert aspect.argnames == ['self', 'b']
assert aspect.flags == 0
assert answ == 7
+ sample_aop_code.clean_module('aop_before_meth_execution')
def test_simple_aspect_after_execution(self):
from aop import PointCut, Aspect, after
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_after_execution')
class AspectTest:
__metaclass__ = Aspect
def __init__(self):
@@ -232,16 +240,18 @@
aspect = AspectTest()
assert __aop__.advices == [(aspect, AspectTest.advice_after_execution)]
assert not aspect.executed
- aop_after_execution = sample_aop_code.import_('aop_after_execution')
+ import aop_after_execution
assert aspect.executed == 0
answ = aop_after_execution.foo(1,2)
assert aspect.executed == 1
assert answ == 47
+ sample_aop_code.clean_module('aop_after_execution')
def test_simple_aspect_around_execution(self):
from aop import PointCut, Aspect, around
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_around_execution')
class AspectTest:
__metaclass__ = Aspect
def __init__(self):
@@ -259,7 +269,7 @@
return tjp.result()
aspect = AspectTest()
- aop_around_execution = sample_aop_code.import_('aop_around_execution')
+ import aop_around_execution
assert aspect.executed_before == 0
assert aspect.executed_after == 0
answ = aop_around_execution.foo(1,2)
@@ -267,13 +277,15 @@
assert aspect.executed_after == 1
assert aspect.result == 47
assert answ == 47
+ sample_aop_code.clean_module('aop_around_execution')
class AppTestWeavingAtCall(BaseAppTest):
def test_simple_aspect_before_call(self):
from aop import PointCut, Aspect, before
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_before_call')
class AspectTest:
__metaclass__ = Aspect
@@ -291,16 +303,18 @@
assert __aop__.advices == [(aspect, AspectTest.advice_before_call)]
assert not aspect.executed
- aop_before_call = sample_aop_code.import_('aop_before_call')
+ import aop_before_call
assert aspect.executed == 0
answ = aop_before_call.foo(1,2)
assert aspect.executed == 1
assert answ == 47
+ sample_aop_code.clean_module('aop_before_call')
def test_simple_aspect_after_call(self):
from aop import PointCut, Aspect, after
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_after_call')
class AspectTest:
__metaclass__ = Aspect
@@ -322,18 +336,20 @@
assert __aop__.advices == [(aspect, AspectTest.advice_after_call)]
assert not aspect.executed
- aop_after_call = sample_aop_code.import_('aop_after_call')
+ import aop_after_call
assert not aspect.executed
answ = aop_after_call.foo(1,2)
assert aspect.executed
assert answ == 47
assert aspect.result == 42
+ sample_aop_code.clean_module('aop_after_call')
def test_simple_aspect_around_call(self):
from aop import PointCut, Aspect, around
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_around_call')
class AspectTest:
__metaclass__ = Aspect
def __init__(self):
@@ -351,7 +367,7 @@
return tjp.result()
aspect = AspectTest()
- aop_around_call = sample_aop_code.import_('aop_around_call')
+ import aop_around_call
assert aspect.executed_before == 0
assert aspect.executed_after == 0
answ = aop_around_call.foo(1,2)
@@ -359,13 +375,15 @@
assert aspect.executed_after == 1
assert aspect.result == 42
assert answ == 47
+ sample_aop_code.clean_module('aop_around_call')
class AppTestWeavingIntroduce(BaseAppTest):
def test_introduce(self):
from aop import PointCut, Aspect, introduce
- from app_test import sample_aop_code
+ import sample_aop_code
__aop__._clear_all()
+ sample_aop_code.write_module('aop_introduce')
class AspectTest:
__metaclass__ = Aspect
@introduce(PointCut(klass='Mumble'))
@@ -373,7 +391,7 @@
return it.p*a+b
aspect = AspectTest()
- aop_introduce = sample_aop_code.import_('aop_introduce')
+ import aop_introduce
c = aop_introduce.Mumble(2)
try:
answ = c.newmethod(1,3)
More information about the Pypy-commit
mailing list