[py-svn] r41860 - in py/trunk/py/test: . testing

fijal at codespeak.net fijal at codespeak.net
Tue Apr 3 19:28:06 CEST 2007


Author: fijal
Date: Tue Apr  3 19:28:04 2007
New Revision: 41860

Modified:
   py/trunk/py/test/defaultconftest.py
   py/trunk/py/test/session.py
   py/trunk/py/test/testing/test_session.py
Log:
* kill start_on
* add keyword_oneshot flag, which indicates that -k is only one shot
  than all tests are run
* simplify code a bit


Modified: py/trunk/py/test/defaultconftest.py
==============================================================================
--- py/trunk/py/test/defaultconftest.py	(original)
+++ py/trunk/py/test/defaultconftest.py	Tue Apr  3 19:28:04 2007
@@ -43,9 +43,9 @@
                action="store", dest="keyword", default='',
                help="only run test items matching the given (google-style) "
                     "keyword expression."),
-        Option('-q', '--start-on',
-               action='store', dest='start_on', default='',
-               help="start from first test matching given keyword expression"),
+        Option('-j', '--keyword-oneshot',
+               action='store_true', dest='keyword_oneshot', default=False,
+               help="combined with -k, runs all tests after first hit"),
         Option('-l', '--showlocals',
                action="store_true", dest="showlocals", default=False,
                help="show locals in tracebacks (disabled by default)."),

Modified: py/trunk/py/test/session.py
==============================================================================
--- py/trunk/py/test/session.py	(original)
+++ py/trunk/py/test/session.py	Tue Apr  3 19:28:04 2007
@@ -9,12 +9,7 @@
     def __init__(self, config): 
         self._memo = []
         self.config = config
-        if config.option.start_on:
-            self.keyword = config.option.start_on
-        elif config.option.keyword:
-            self.keyword = config.option.keyword
-        else:
-            self.keyword = None
+        self._keyword = config.option.keyword
 
     def shouldclose(self): 
         return False 
@@ -45,8 +40,8 @@
         if option.executable and option.usepdb:
             raise ValueError, "--exec together with --pdb not supported."
 
-        if option.keyword and option.start_on:
-            raise ValueError, "--start-on and --keyword not supported"
+        if option.keyword_oneshot and not option.keyword:
+            raise ValueError, "--keyword-oneshot makes sense only when --keyword is supplied"
 
     def start(self, colitem): 
         """ hook invoked before each colitem.run() invocation. """ 
@@ -111,9 +106,9 @@
         if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item): 
             return
         if isinstance(colitem, py.test.collect.Item):
-            colitem._skipbykeyword(self.keyword)
-            if self.config.option.start_on:
-                self.keyword = ""
+            colitem._skipbykeyword(self._keyword)
+            if self.config.option.keyword_oneshot:
+                self._keyword = ""
         res = colitem.run() 
         if res is None:
             return Passed() 

Modified: py/trunk/py/test/testing/test_session.py
==============================================================================
--- py/trunk/py/test/testing/test_session.py	(original)
+++ py/trunk/py/test/testing/test_session.py	Tue Apr  3 19:28:04 2007
@@ -12,7 +12,6 @@
 conflict_options = ('--looponfailing --pdb',
                     '--dist --pdb', 
                     '--exec=%s --pdb' % py.std.sys.executable,
-                    '-k xxx -q xxx',
                    )
 
 def test_conflict_options():
@@ -100,7 +99,7 @@
 
     def test_select_starton(self):
         config = py.test.config._reparse([datadir/'testmore.py', 
-                                          '-q', "test_two"])
+                                          '-j', '-k', "test_two"])
         session = config._getsessionclass()(config, py.std.sys.stdout)
         session.main()
         l = session.getitemoutcomepairs(Passed)



More information about the pytest-commit mailing list