diff options
| author | Jonathan Lange <jml@canonical.com> | 2010-10-17 16:05:09 +0100 |
|---|---|---|
| committer | Jonathan Lange <jml@canonical.com> | 2010-10-17 16:05:09 +0100 |
| commit | 2692fd4757699f0dd9fa40c5c604c38617ecd8a2 (patch) | |
| tree | a8b5ba7c22f57e0a09c01262d7b91a6842661088 /testtools/tests/test_runtest.py | |
| parent | d33a9f9055dd89692641d6a0e7686d19afbf7b6e (diff) | |
| download | testtools-2692fd4757699f0dd9fa40c5c604c38617ecd8a2.tar.gz | |
Make the runTest argument actually work.
Diffstat (limited to 'testtools/tests/test_runtest.py')
| -rw-r--r-- | testtools/tests/test_runtest.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testtools/tests/test_runtest.py b/testtools/tests/test_runtest.py index a4c0a72..e01213a 100644 --- a/testtools/tests/test_runtest.py +++ b/testtools/tests/test_runtest.py @@ -8,6 +8,7 @@ from testtools import ( TestCase, TestResult, ) +from testtools.matchers import Is from testtools.tests.helpers import ExtendedTestResult @@ -176,6 +177,30 @@ class TestRunTest(TestCase): ], result._events) +class CustomRunTest(RunTest): + + def __init__(self, marker, *args, **kwargs): + super(CustomRunTest, self).__init__(*args, **kwargs) + self._marker = marker + + def run(self, result=None): + return self._marker + + +class TestTestCaseSupportForRunTest(TestCase): + + def test_pass_custom_run_test(self): + class SomeCase(TestCase): + def test_foo(self): + pass + result = TestResult() + marker = object() + case = SomeCase( + 'test_foo', runTest=lambda *args: CustomRunTest(marker, *args)) + from_run_test = case.run(result) + self.assertThat(from_run_test, Is(marker)) + + def test_suite(): from unittest import TestLoader return TestLoader().loadTestsFromName(__name__) |
