2 new commits in pytest:
https://bitbucket.org/hpk42/pytest/changeset/ef59b755c115/ changeset: ef59b755c115 user: hpk42 date: 2012-10-22 16:12:22 summary: make sure ihook uses a node's fspath - important for hooks e.g. during a Module's collect to pick up conftest.py files residing in the same dir affected #: 6 files diff -r 3d4ebcbd4079e310abdc4ab53941527ebb6e67fd -r ef59b755c115b2d0344404b11ca922220bbbd329 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -2,20 +2,22 @@ ----------------------------------- - fix issue205 - conftests in subdirs customizing - pytest_pycollect_makemodule now work properly + pytest_pycollect_makemodule and pytest_pycollect_makeitem + now work properly - fix teardown-ordering for parametrized setups -- fix exception message check of test_nose.py to pass on python33 as well +- "python setup.py test" now works with pytest itself -- fix issue206 - fix test_assertrewrite.py to work when a global - PYTHONDONTWRITEBYTECODE=1 is present +- fix/improve internal/packaging related bits: -- add tox.ini to pytest distribution so that ignore-dirs and others config - bits are properly distributed for maintainers who run pytest-own tests + - exception message check of test_nose.py now passes on python33 as well -- add some logic to setup.py such that "python setup.py test" works with - pytest itself + - issue206 - fix test_assertrewrite.py to work when a global + PYTHONDONTWRITEBYTECODE=1 is present + + - add tox.ini to pytest distribution so that ignore-dirs and others config + bits are properly distributed for maintainers who run pytest-own tests Changes between 2.3.0 and 2.3.1 ----------------------------------- diff -r 3d4ebcbd4079e310abdc4ab53941527ebb6e67fd -r ef59b755c115b2d0344404b11ca922220bbbd329 _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.2.dev6' +__version__ = '2.3.2.dev7' diff -r 3d4ebcbd4079e310abdc4ab53941527ebb6e67fd -r ef59b755c115b2d0344404b11ca922220bbbd329 _pytest/main.py --- a/_pytest/main.py +++ b/_pytest/main.py @@ -211,14 +211,16 @@ #: filesystem path where this node was collected from (can be None) self.fspath = getattr(parent, 'fspath', None) - #: fspath sensitive hook proxy used to call pytest hooks - self.ihook = self.session.gethookproxy(self.fspath) - #: keywords/markers collected from all scopes self.keywords = NodeKeywords(self) #self.extrainit() + @property + def ihook(self): + """ fspath sensitive hook proxy used to call pytest hooks""" + return self.session.gethookproxy(self.fspath) + #def extrainit(self): # """"extra initialization after Node is initialized. Implemented # by some subclasses. """ diff -r 3d4ebcbd4079e310abdc4ab53941527ebb6e67fd -r ef59b755c115b2d0344404b11ca922220bbbd329 _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -288,6 +288,7 @@ return l def makeitem(self, name, obj): + #assert self.ihook.fspath == self.fspath, self return self.ihook.pytest_pycollect_makeitem( collector=self, name=name, obj=obj) diff -r 3d4ebcbd4079e310abdc4ab53941527ebb6e67fd -r ef59b755c115b2d0344404b11ca922220bbbd329 setup.py --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.2.dev6', + version='2.3.2.dev7', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -r 3d4ebcbd4079e310abdc4ab53941527ebb6e67fd -r ef59b755c115b2d0344404b11ca922220bbbd329 testing/test_python.py --- a/testing/test_python.py +++ b/testing/test_python.py @@ -419,6 +419,28 @@ reprec = testdir.inline_run() reprec.assertoutcome(passed=1) + def test_customized_pymakeitem(self, testdir): + b = testdir.mkdir("a").mkdir("b") + b.join("conftest.py").write(py.code.Source(""" + def pytest_pycollect_makeitem(__multicall__): + result = __multicall__.execute() + if result: + for func in result: + func._some123 = "world" + return result + """)) + b.join("test_module.py").write(py.code.Source(""" + import pytest + + @pytest.fixture() + def obj(request): + return request.node._some123 + def test_hello(obj): + assert obj == "world" + """)) + reprec = testdir.inline_run() + reprec.assertoutcome(passed=1) + def test_pytest_pycollect_makeitem(self, testdir): testdir.makeconftest(""" import pytest https://bitbucket.org/hpk42/pytest/changeset/65a3b9540751/ changeset: 65a3b9540751 user: hpk42 date: 2012-10-22 16:25:09 summary: fix unittest emulation: TestCase.runTest is now ignored if there are test* methods. affected #: 5 files diff -r ef59b755c115b2d0344404b11ca922220bbbd329 -r 65a3b95407512a9492e5cd755768c7f6022ab77f CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,9 @@ - fix teardown-ordering for parametrized setups +- fix unittest behaviour: TestCase.runtest only called if there are + test methods defined + - "python setup.py test" now works with pytest itself - fix/improve internal/packaging related bits: diff -r ef59b755c115b2d0344404b11ca922220bbbd329 -r 65a3b95407512a9492e5cd755768c7f6022ab77f _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.2.dev7' +__version__ = '2.3.2.dev8' diff -r ef59b755c115b2d0344404b11ca922220bbbd329 -r 65a3b95407512a9492e5cd755768c7f6022ab77f _pytest/unittest.py --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -28,6 +28,7 @@ loader = py.std.unittest.TestLoader() module = self.getparent(pytest.Module).obj cls = self.obj + foundsomething = False for name in loader.getTestCaseNames(self.obj): x = getattr(self.obj, name) funcobj = getattr(x, 'im_func', x) @@ -35,9 +36,11 @@ if hasattr(funcobj, 'todo'): pytest.mark.xfail(reason=str(funcobj.todo))(funcobj) yield TestCaseFunction(name, parent=self) + foundsomething = True - if getattr(self.obj, 'runTest', None) is not None: - yield TestCaseFunction('runTest', parent=self) + if not foundsomething: + if getattr(self.obj, 'runTest', None) is not None: + yield TestCaseFunction('runTest', parent=self) def setup(self): meth = getattr(self.obj, 'setUpClass', None) diff -r ef59b755c115b2d0344404b11ca922220bbbd329 -r 65a3b95407512a9492e5cd755768c7f6022ab77f setup.py --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.2.dev7', + version='2.3.2.dev8', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -r ef59b755c115b2d0344404b11ca922220bbbd329 -r 65a3b95407512a9492e5cd755768c7f6022ab77f testing/test_unittest.py --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -18,12 +18,21 @@ testpath=testdir.makepyfile(""" import unittest pytest_plugins = "pytest_unittest" - class MyTestCase(unittest.TestCase): + class MyTestCaseWithRunTest(unittest.TestCase): def runTest(self): self.assertEquals('foo', 'foo') + class MyTestCaseWithoutRunTest(unittest.TestCase): + def runTest(self): + self.assertEquals('foo', 'foo') + def test_something(self): + pass """) - reprec = testdir.inline_run(testpath) - assert reprec.matchreport('runTest').passed + result = testdir.runpytest("-v") + result.stdout.fnmatch_lines(""" + *MyTestCaseWithRunTest.runTest* + *MyTestCaseWithoutRunTest.test_something* + *2 passed* + """) def test_isclasscheck_issue53(testdir): testpath = testdir.makepyfile(""" Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ py-svn mailing list py-svn@codespeak.net http://codespeak.net/mailman/listinfo/py-svn