From 1b3fb3d2292ed2dd046f1721cce9128aa4317112 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 11 Jan 2011 17:27:34 +0100 Subject: [PATCH] fix issue15 - tests for python3/nose-1.0 combo work now --- CHANGELOG | 2 ++ pytest.py | 2 +- setup.py | 2 +- testing/test_nose.py | 39 +++++++++++++++++++++------------------ tox.ini | 1 + 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4e4ee0a80..ce507a89d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ Changes between 2.0.0 and 2.0.1.devX ---------------------------------------------- +- fix issue15: make nose compatibility tests compatible + with python3 (now that nose-1.0 supports python3) - remove somewhat surprising "same-conftest" detection because it ignores conftest.py when they appear in several subdirs. - improve assertions ("not in"), thanks Floris diff --git a/pytest.py b/pytest.py index 68d2fb50b..cfb48e5e7 100644 --- a/pytest.py +++ b/pytest.py @@ -1,7 +1,7 @@ """ unit and functional testing with Python. """ -__version__ = '2.0.1.dev5' +__version__ = '2.0.1.dev6' __all__ = ['main'] from _pytest.core import main, UsageError, _preloadplugins diff --git a/setup.py b/setup.py index d1a459315..0b3a1426d 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.1.dev5', + version='2.0.1.dev6', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_nose.py b/testing/test_nose.py index 317a3041a..4ce7cdf76 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -6,7 +6,9 @@ def setup_module(mod): def test_nose_setup(testdir): p = testdir.makepyfile(""" l = [] + from nose.tools import with_setup + @with_setup(lambda: l.append(1), lambda: l.append(2)) def test_hello(): assert l == [1] @@ -24,6 +26,8 @@ def test_nose_setup(testdir): def test_nose_setup_func(testdir): p = testdir.makepyfile(""" + from nose.tools import with_setup + l = [] def my_setup(): @@ -34,16 +38,15 @@ def test_nose_setup_func(testdir): b = 2 l.append(b) + @with_setup(my_setup, my_teardown) def test_hello(): - print l + print (l) assert l == [1] def test_world(): - print l + print (l) assert l == [1,2] - test_hello.setup = my_setup - test_hello.teardown = my_teardown """) result = testdir.runpytest(p, '-p', 'nose') result.stdout.fnmatch_lines([ @@ -53,25 +56,25 @@ def test_nose_setup_func(testdir): def test_nose_setup_func_failure(testdir): p = testdir.makepyfile(""" - l = [] + from nose.tools import with_setup + l = [] my_setup = lambda x: 1 my_teardown = lambda x: 2 + @with_setup(my_setup, my_teardown) def test_hello(): - print l + print (l) assert l == [1] def test_world(): - print l + print (l) assert l == [1,2] - test_hello.setup = my_setup - test_hello.teardown = my_teardown """) result = testdir.runpytest(p, '-p', 'nose') result.stdout.fnmatch_lines([ - "*TypeError: () takes exactly 1 argument (0 given)*" + "*TypeError: () takes exactly 1*0 given*" ]) @@ -83,11 +86,11 @@ def test_nose_setup_func_failure_2(testdir): my_teardown = 2 def test_hello(): - print l + print (l) assert l == [1] def test_world(): - print l + print (l) assert l == [1,2] test_hello.setup = my_setup @@ -118,11 +121,11 @@ def test_nose_setup_partial(testdir): my_teardown_partial = partial(my_teardown, 2) def test_hello(): - print l + print (l) assert l == [1] def test_world(): - print l + print (l) assert l == [1,2] test_hello.setup = my_setup_partial @@ -173,21 +176,21 @@ def test_nose_test_generator_fixtures(testdir): class TestClass(object): def setup(self): - print "setup called in", self + print ("setup called in %s" % self) self.called = ['setup'] def teardown(self): - print "teardown called in", self + print ("teardown called in %s" % self) eq_(self.called, ['setup']) self.called.append('teardown') def test(self): - print "test called in", self + print ("test called in %s" % self) for i in range(0, 5): yield self.check, i def check(self, i): - print "check called in", self + print ("check called in %s" % self) expect = ['setup'] #for x in range(0, i): # expect.append('setup') diff --git a/tox.ini b/tox.ini index 0d7630ee5..77b25df2c 100644 --- a/tox.ini +++ b/tox.ini @@ -49,6 +49,7 @@ commands= [testenv:py31] deps=py>=1.4.0 + nose>=1.0 [testenv:py31-xdist] deps=pytest-xdist