[py-svn] r61961 - in py/trunk/py: doc test

hpk at codespeak.net hpk at codespeak.net
Tue Feb 17 09:56:30 CET 2009


Author: hpk
Date: Tue Feb 17 09:56:29 2009
New Revision: 61961

Modified:
   py/trunk/py/doc/test.txt
   py/trunk/py/test/defaultconftest.py
Log:
improve documentation about "-k" keyword handling.


Modified: py/trunk/py/doc/test.txt
==============================================================================
--- py/trunk/py/doc/test.txt	(original)
+++ py/trunk/py/doc/test.txt	Tue Feb 17 09:56:29 2009
@@ -139,8 +139,8 @@
 
 .. _`selection by keyword`: 
 
-selecting tests by keyword 
---------------------------
+selecting/unselecting tests by keyword 
+---------------------------------------------
 
 You can selectively run tests by specifiying a keyword 
 on the command line. Example:: 
@@ -151,10 +151,20 @@
 and where the word "test_simple" equals the start of one part of the 
 path  leading up to the test item.  Directory and file basenames as well 
 as function, class and function/method names each form a possibly
-matching name. 
+matching name.   You can also unselect tests by preceding a keyword 
+with a dash:: 
+
+    py.test. -k "-test_simple"
+
+will run all tests except where the word "test_simple" matches a tests keyword. 
+Note that you need to quote the keyword if the shell recognizes "-" as an intro
+to a cmdline option.  Lastly, you may use 
+
+    py.test. -k "test_simple:"
 
-    Note that the exact semantics are still experimental but 
-    should always remain intuitive.   
+which will run all tests after the expression has *matched once*, i.e. 
+all tests that are seen after a test that matches the "test_simple" 
+keyword. 
 
 testing with multiple python versions / executables 
 ---------------------------------------------------

Modified: py/trunk/py/test/defaultconftest.py
==============================================================================
--- py/trunk/py/test/defaultconftest.py	(original)
+++ py/trunk/py/test/defaultconftest.py	Tue Feb 17 09:56:29 2009
@@ -42,7 +42,9 @@
         Option('-k',
                action="store", dest="keyword", default='',
                help="only run test items matching the given "
-                    "keyword expression."),
+                    "comma separated keywords.  precede keyword with '-' to negate. "
+                    "Terminate with ':' to treat a match as a signal to run all subsequent tests. "
+         ),
         Option('-l', '--showlocals',
                action="store_true", dest="showlocals", default=False,
                help="show locals in tracebacks (disabled by default)."),



More information about the pytest-commit mailing list