From 5e77eb23ebd0b9a3ad34eb65892790482c64b610 Mon Sep 17 00:00:00 2001 From: Brian Okken Date: Sat, 22 Jun 2013 09:35:10 -0700 Subject: [PATCH] add test_unittest_style_setup_teardown() to test setUpModule() and tearDownModule() --- testing/test_unittest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/test_unittest.py b/testing/test_unittest.py index eecc9da68..74c499939 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -65,6 +65,28 @@ def test_setup(testdir): 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