[py-svn] r41480 - py/trunk/py/test
arigo at codespeak.net
arigo at codespeak.net
Tue Mar 27 15:28:21 CEST 2007
Author: arigo
Date: Tue Mar 27 15:28:18 2007
New Revision: 41480
Modified:
py/trunk/py/test/collect.py
py/trunk/py/test/item.py
Log:
Move the FunctionMixin to collect.py, as an attempt to avoid circular
imports.
Modified: py/trunk/py/test/collect.py
==============================================================================
--- py/trunk/py/test/collect.py (original)
+++ py/trunk/py/test/collect.py Tue Mar 27 15:28:18 2007
@@ -442,7 +442,38 @@
Collector.Function.__get__(self)) # XXX for python 2.2
Function = property(Function)
-from py.__.test.item import FunctionMixin # XXX import order issues :-(
+
+class FunctionMixin(object):
+ """ mixin for the code common to Function and Generator.
+ """
+ def _getpathlineno(self):
+ code = py.code.Code(self.obj)
+ return code.path, code.firstlineno
+
+ def _getsortvalue(self):
+ return self._getpathlineno()
+
+ def setup(self):
+ """ perform setup for this test function. """
+ if getattr(self.obj, 'im_self', None):
+ name = 'setup_method'
+ else:
+ name = 'setup_function'
+ obj = self.parent.obj
+ meth = getattr(obj, name, None)
+ if meth is not None:
+ return meth(self.obj)
+
+ def teardown(self):
+ """ perform teardown for this test function. """
+ if getattr(self.obj, 'im_self', None):
+ name = 'teardown_method'
+ else:
+ name = 'teardown_function'
+ obj = self.parent.obj
+ meth = getattr(obj, name, None)
+ if meth is not None:
+ return meth(self.obj)
class Generator(FunctionMixin, PyCollectorMixin, Collector):
def run(self):
Modified: py/trunk/py/test/item.py
==============================================================================
--- py/trunk/py/test/item.py (original)
+++ py/trunk/py/test/item.py Tue Mar 27 15:28:18 2007
@@ -2,6 +2,7 @@
from inspect import isclass, ismodule
from py.__.test.outcome import Skipped, Failed, Passed
+from py.__.test.collect import FunctionMixin
_dummy = object()
@@ -37,38 +38,6 @@
def finishcapture(self):
self._config._finishcapture(self)
-class FunctionMixin(object):
- """ mixin for the code common to Function and Generator.
- """
- def _getpathlineno(self):
- code = py.code.Code(self.obj)
- return code.path, code.firstlineno
-
- def _getsortvalue(self):
- return self._getpathlineno()
-
- def setup(self):
- """ perform setup for this test function. """
- if getattr(self.obj, 'im_self', None):
- name = 'setup_method'
- else:
- name = 'setup_function'
- obj = self.parent.obj
- meth = getattr(obj, name, None)
- if meth is not None:
- return meth(self.obj)
-
- def teardown(self):
- """ perform teardown for this test function. """
- if getattr(self.obj, 'im_self', None):
- name = 'teardown_method'
- else:
- name = 'teardown_function'
- obj = self.parent.obj
- meth = getattr(obj, name, None)
- if meth is not None:
- return meth(self.obj)
-
class Function(FunctionMixin, Item):
""" a Function Item is responsible for setting up
and executing a Python callable test object.
More information about the py-svn
mailing list