[Pytest-commit] commit/pytest: RonnyPfannschmidt: move looponchange related code to the looponchange plugin

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Mar 14 10:57:01 CET 2015


1 new commit in pytest:

https://bitbucket.org/pytest-dev/pytest/commits/b5727cc6632c/
Changeset:   b5727cc6632c
Branch:      merge-cache
User:        RonnyPfannschmidt
Date:        2015-03-14 09:56:49+00:00
Summary:     move looponchange related code to the looponchange plugin
Affected #:  2 files

diff -r 0693d6b045fbf3dbf807cf26d6f9eacbc850e35d -r b5727cc6632c148ce6b3ef27f46d980b0f90034f _pytest/cache.py
--- a/_pytest/cache.py
+++ b/_pytest/cache.py
@@ -135,12 +135,6 @@
 
 
 def pytest_addoption(parser):
-    try:
-        outside_looponfail = pkg_resources.resource_exists(
-            'xdist', 'looponfail.py')
-    except ImportError:
-        outside_looponfail = False
-
     group = parser.getgroup("general")
     group.addoption(
         '--lf', action='store_true', dest="lf",
@@ -157,25 +151,13 @@
     group.addoption(
         '--clearcache', action='store_true', dest="clearcache",
         help="remove all cache contents at start of test run.")
-    group.addoption(
-        '--looponchange', action='store_true', dest='looponchange',
-        help='rerun every time the workdir changes')
-    if not outside_looponfail:
-        group._addoption(
-            '-f', '--looponfail', action='store_true', dest='looponfail',
-            help='rerun every time the workdir changes')
-    parser.addini(
-        "looponchangeroots", type="pathlist",
-        help="directories to check for changes", default=[py.path.local()])
+
 
 
 def pytest_cmdline_main(config):
     if config.option.showcache:
         from _pytest.main import wrap_session
         return wrap_session(config, showcache)
-    if config.option.looponchange or config.option.looponfail:
-        from .onchange import looponchange
-        return looponchange(config)
 
 
 @pytest.mark.tryfirst

diff -r 0693d6b045fbf3dbf807cf26d6f9eacbc850e35d -r b5727cc6632c148ce6b3ef27f46d980b0f90034f _pytest/onchange.py
--- a/_pytest/onchange.py
+++ b/_pytest/onchange.py
@@ -7,8 +7,33 @@
 """
 
 
+def pytest_addoption(parser):
+    try:
+        outside_looponfail = pkg_resources.resource_exists(
+            'xdist', 'looponfail.py')
+    except ImportError:
+        outside_looponfail = False
+
+    group = parser.getgroup("general")
+    group.addoption(
+        '--looponchange', action='store_true', dest='looponchange',
+        help='rerun every time the workdir changes')
+    if not outside_looponfail:
+        group._addoption(
+            '-f', '--looponfail', action='store_true', dest='looponfail',
+            help='rerun every time the workdir changes')
+    parser.addini(
+        "looponchangeroots", type="pathlist",
+        help="directories to check for changes", default=[py.path.local()])
+
+
+def pytest_cmdline_main(config):
+    if config.option.looponchange or config.option.looponfail:
+        return looponchange(config)
+
+
 def run_once(args, tw=None):
-    tw = py.io.TerminalWriter()
+    tw = tw or py.io.TerminalWriter()
     subprocess.call(args)
     tw.line()
     tw.sep('#', 'waiting for changes')
@@ -21,6 +46,9 @@
         newargs.remove('--looponchange')
     else:
         newargs.remove('-f')
+    if '--looponfail' in newargs:
+        newargs.remove('--looponfail')
+        newargs.append('--lf')
     stats = StatRecorder(config.getini('looponchangeroots'))
     command = py.std.functools.partial(run_once, [
             py.std.sys.executable, '-c', SCRIPT % newargs])

Repository URL: https://bitbucket.org/pytest-dev/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list