]> granicus.if.org Git - python/commitdiff
a more realistic example
authorBenjamin Peterson <benjamin@python.org>
Sun, 29 Mar 2009 03:16:57 +0000 (03:16 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 29 Mar 2009 03:16:57 +0000 (03:16 +0000)
Doc/library/unittest.rst

index 4f321dc357239366c0f027852b983ce97c60e1a1..0aa55a6c41fc891112873d024cb9d4e1b09cb90d 100644 (file)
@@ -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: ::