3 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/a6b43681c095/ Changeset: a6b43681c095 User: variedthoughts Date: 2013-06-20 16:43:42 Summary: support unittest setUpModule/tearDownModule Affected #: 1 file
diff -r b4b8fcf30a4b8ee5974c1ba75642f8b6ac5d9c3d -r a6b43681c095cf385b81926cadc5eb629ef4f8bc _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -371,7 +371,9 @@ return mod def setup(self): - setup_module = xunitsetup(self.obj, "setup_module") + setup_module = xunitsetup(self.obj, "setUpModule") + if setup_module is None: + setup_module = xunitsetup(self.obj, "setup_module") if setup_module is not None: #XXX: nose compat hack, move to nose plugin # if it takes a positional arg, its probably a pytest style one @@ -382,7 +384,9 @@ setup_module() def teardown(self): - teardown_module = xunitsetup(self.obj, 'teardown_module') + teardown_module = xunitsetup(self.obj, 'tearDownModule') + if teardown_module is None: + teardown_module = xunitsetup(self.obj, 'teardown_module') if teardown_module is not None: #XXX: nose compat hack, move to nose plugin # if it takes a positional arg, its probably a py.test style one https://bitbucket.org/hpk42/pytest/commits/e5e97a902d49/ Changeset: e5e97a902d49 User: Brian Okken Date: 2013-06-22 18:35:10 Summary: add test_unittest_style_setup_teardown() to test setUpModule() and tearDownModule() Affected #: 1 file diff -r a6b43681c095cf385b81926cadc5eb629ef4f8bc -r e5e97a902d4998fce36e99dfbceb099cb410eda7 testing/test_unittest.py --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -65,6 +65,28 @@ rep = reprec.matchreport("test_both", when="teardown") assert rep.failed and '42' in str(rep.longrepr) +def test_unittest_style_setup_teardown(testdir): + testdir.makepyfile(""" + l = [] + + def setUpModule(): + l.append(1) + + def tearDownModule(): + del l[0] + + def test_hello(): + assert l == [1] + + def test_world(): + assert l == [1] + """) + result = testdir.runpytest('-p', 'nose') + result.stdout.fnmatch_lines([ + "*2 passed*", + ]) + + def test_new_instances(testdir): testpath = testdir.makepyfile(""" import unittest https://bitbucket.org/hpk42/pytest/commits/0df9999d1bd0/ Changeset: 0df9999d1bd0 User: Brian Okken Date: 2013-06-22 18:42:31 Summary: change how the test is called Affected #: 1 file diff -r e5e97a902d4998fce36e99dfbceb099cb410eda7 -r 0df9999d1bd00ba3f109dcc76398b861744b15b1 testing/test_unittest.py --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -66,7 +66,7 @@ assert rep.failed and '42' in str(rep.longrepr) def test_unittest_style_setup_teardown(testdir): - testdir.makepyfile(""" + testpath = testdir.makepyfile(""" l = [] def setUpModule(): @@ -81,7 +81,7 @@ def test_world(): assert l == [1] """) - result = testdir.runpytest('-p', 'nose') + result = testdir.runpytest(testpath) result.stdout.fnmatch_lines([ "*2 passed*", ]) 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. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit