summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-29 03:16:57 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-29 03:16:57 (GMT)
commitbe76d4caed3a0aa35ce1c878152c9576d71ff145 (patch)
tree80ff6992ffcc42272c328794fdca7fb5c2a08019
parenta0eea590c7707b65558934b59a2a8b1567261bab (diff)
downloadcpython-be76d4caed3a0aa35ce1c878152c9576d71ff145.zip
cpython-be76d4caed3a0aa35ce1c878152c9576d71ff145.tar.gz
cpython-be76d4caed3a0aa35ce1c878152c9576d71ff145.tar.bz2
a more realistic example
-rw-r--r--Doc/library/unittest.rst16
1 files changed, 15 insertions, 1 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 4f321dc..0aa55a6 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -447,12 +447,26 @@ Basic skipping looks like this: ::
def test_nothing(self):
self.fail("shouldn't happen")
+ @unittest.skipIf(mylib.__version__ < (1, 3), "not supported in this library version")
+ def test_format(self):
+ # 2.6+ only code here.
+ pass
+
+ @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
+ def test_windows_support(self):
+ # windows specific testing code
+ pass
+
This is the output of running the example above in verbose mode: ::
+ test_format (__main__.MyTestCase) ... skipped 'not supported in this Python version'
test_nothing (__main__.MyTestCase) ... skipped 'demonstrating skipping'
+ test_windows_support (__main__.MyTestCase) ... skipped 'requires Windows'
----------------------------------------------------------------------
- Ran 1 test in 0.072s
+ Ran 3 tests in 0.005s
+
+ OK (skipped=3)
Classes can be skipped just like methods: ::