summaryrefslogtreecommitdiff
path: root/testtools/tests/test_testcase.py
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2014-11-17 15:42:11 +1300
committerRobert Collins <robertc@robertcollins.net>2014-11-17 15:42:11 +1300
commitd30ee53f2eeb9ce4c4a04b7f6e94063edab72611 (patch)
treefabc78a989393de15dfe85ade7fffefafc31c1b8 /testtools/tests/test_testcase.py
parentf6034dd583c8c4d9f7740cb70ffe6ffd5cab1aee (diff)
downloadtesttools-d30ee53f2eeb9ce4c4a04b7f6e94063edab72611.tar.gz
Fix setUpClass upcalls on Python 2.6.
``testtools.TestCase`` now inherits from unittest2.TestCase, which provides a ``setUpClass`` for upcalls on Python 2.6. (Robert Collins, #1393283) Change-Id: Id56212e3d7d519c7b73d2e19d3e34013fac34544
Diffstat (limited to 'testtools/tests/test_testcase.py')
-rw-r--r--testtools/tests/test_testcase.py47
1 files changed, 25 insertions, 22 deletions
diff --git a/testtools/tests/test_testcase.py b/testtools/tests/test_testcase.py
index eef96ed..185b726 100644
--- a/testtools/tests/test_testcase.py
+++ b/testtools/tests/test_testcase.py
@@ -1602,40 +1602,43 @@ class TestNullary(TestCase):
self.assertRaises(ZeroDivisionError, wrapped)
+class Attributes(WithAttributes, TestCase):
+ @attr('foo')
+ def simple(self):
+ pass
+
+ # Not sorted here, forward or backwards.
+ @attr('foo', 'quux', 'bar')
+ def many(self):
+ pass
+
+ # Not sorted here, forward or backwards.
+ @attr('bar')
+ @attr('quux')
+ @attr('foo')
+ def decorated(self):
+ pass
+
+
class TestAttributes(TestCase):
def test_simple_attr(self):
# Adding an attr to a test changes its id().
- class MyTest(WithAttributes, TestCase):
- @attr('foo')
- def test_bar(self):
- pass
- case = MyTest('test_bar')
- self.assertEqual('testtools.tests.test_testcase.MyTest.test_bar[foo]',
+ case = Attributes('simple')
+ self.assertEqual(
+ 'testtools.tests.test_testcase.Attributes.simple[foo]',
case.id())
def test_multiple_attributes(self):
- class MyTest(WithAttributes, TestCase):
- # Not sorted here, forward or backwards.
- @attr('foo', 'quux', 'bar')
- def test_bar(self):
- pass
- case = MyTest('test_bar')
+ case = Attributes('many')
self.assertEqual(
- 'testtools.tests.test_testcase.MyTest.test_bar[bar,foo,quux]',
+ 'testtools.tests.test_testcase.Attributes.many[bar,foo,quux]',
case.id())
def test_multiple_attr_decorators(self):
- class MyTest(WithAttributes, TestCase):
- # Not sorted here, forward or backwards.
- @attr('bar')
- @attr('quux')
- @attr('foo')
- def test_bar(self):
- pass
- case = MyTest('test_bar')
+ case = Attributes('decorated')
self.assertEqual(
- 'testtools.tests.test_testcase.MyTest.test_bar[bar,foo,quux]',
+ 'testtools.tests.test_testcase.Attributes.decorated[bar,foo,quux]',
case.id())