[Pytest-commit] commit/pytest: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jan 19 22:34:47 CET 2015


2 new commits in pytest:

https://bitbucket.org/hpk42/pytest/commits/2b5be564845e/
Changeset:   2b5be564845e
Branch:      pastebin-xdist
User:        nicoddemus
Date:        2015-01-19 21:20:01+00:00
Summary:     Attempting to patch terminal only if terminalreporter is available

This fixes the flag "--paste=all" when running tests with xdist, as slaves would
attempt to patch a non-existing terminal during pytest_configure. Only the master
node has a terminalreporter installed.
Affected #:  1 file

diff -r d942d16857f3fd225d25bc21aa6531449163528c -r 2b5be564845e868700a50c23ebcf89b62fdf38d7 _pytest/pastebin.py
--- a/_pytest/pastebin.py
+++ b/_pytest/pastebin.py
@@ -14,13 +14,17 @@
 @pytest.mark.trylast
 def pytest_configure(config):
     if config.option.pastebin == "all":
-        config._pastebinfile = tempfile.TemporaryFile('w+')
         tr = config.pluginmanager.getplugin('terminalreporter')
-        oldwrite = tr._tw.write
-        def tee_write(s, **kwargs):
-            oldwrite(s, **kwargs)
-            config._pastebinfile.write(str(s))
-        tr._tw.write = tee_write
+        # if no terminal reporter plugin is present, nothing we can do here;
+        # this can happen when this function executes in a slave node
+        # when using pytest-xdist, for example
+        if tr is not None:
+            config._pastebinfile = tempfile.TemporaryFile('w+')
+            oldwrite = tr._tw.write
+            def tee_write(s, **kwargs):
+                oldwrite(s, **kwargs)
+                config._pastebinfile.write(str(s))
+            tr._tw.write = tee_write
 
 def pytest_unconfigure(config):
     if hasattr(config, '_pastebinfile'):


https://bitbucket.org/hpk42/pytest/commits/fa62c5c63c2f/
Changeset:   fa62c5c63c2f
User:        hpk42
Date:        2015-01-19 21:34:43+00:00
Summary:     Merged in nicoddemus/pytest/pastebin-xdist (pull request #239)

Using pytest-xdist and --paste=all results in error
Affected #:  1 file

diff -r d942d16857f3fd225d25bc21aa6531449163528c -r fa62c5c63c2fb5870852676d8d8899b9656214fd _pytest/pastebin.py
--- a/_pytest/pastebin.py
+++ b/_pytest/pastebin.py
@@ -14,13 +14,17 @@
 @pytest.mark.trylast
 def pytest_configure(config):
     if config.option.pastebin == "all":
-        config._pastebinfile = tempfile.TemporaryFile('w+')
         tr = config.pluginmanager.getplugin('terminalreporter')
-        oldwrite = tr._tw.write
-        def tee_write(s, **kwargs):
-            oldwrite(s, **kwargs)
-            config._pastebinfile.write(str(s))
-        tr._tw.write = tee_write
+        # if no terminal reporter plugin is present, nothing we can do here;
+        # this can happen when this function executes in a slave node
+        # when using pytest-xdist, for example
+        if tr is not None:
+            config._pastebinfile = tempfile.TemporaryFile('w+')
+            oldwrite = tr._tw.write
+            def tee_write(s, **kwargs):
+                oldwrite(s, **kwargs)
+                config._pastebinfile.write(str(s))
+            tr._tw.write = tee_write
 
 def pytest_unconfigure(config):
     if hasattr(config, '_pastebinfile'):

Repository URL: https://bitbucket.org/hpk42/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