Merged in nicoddemus/pytest/pastebin-xdist (pull request #239)
Using pytest-xdist and --paste=all results in error
This commit is contained in:
		
						commit
						394367e1d2
					
				| 
						 | 
					@ -14,13 +14,17 @@ def pytest_addoption(parser):
 | 
				
			||||||
@pytest.mark.trylast
 | 
					@pytest.mark.trylast
 | 
				
			||||||
def pytest_configure(config):
 | 
					def pytest_configure(config):
 | 
				
			||||||
    if config.option.pastebin == "all":
 | 
					    if config.option.pastebin == "all":
 | 
				
			||||||
        config._pastebinfile = tempfile.TemporaryFile('w+')
 | 
					 | 
				
			||||||
        tr = config.pluginmanager.getplugin('terminalreporter')
 | 
					        tr = config.pluginmanager.getplugin('terminalreporter')
 | 
				
			||||||
        oldwrite = tr._tw.write
 | 
					        # if no terminal reporter plugin is present, nothing we can do here;
 | 
				
			||||||
        def tee_write(s, **kwargs):
 | 
					        # this can happen when this function executes in a slave node
 | 
				
			||||||
            oldwrite(s, **kwargs)
 | 
					        # when using pytest-xdist, for example
 | 
				
			||||||
            config._pastebinfile.write(str(s))
 | 
					        if tr is not None:
 | 
				
			||||||
        tr._tw.write = tee_write
 | 
					            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):
 | 
					def pytest_unconfigure(config):
 | 
				
			||||||
    if hasattr(config, '_pastebinfile'):
 | 
					    if hasattr(config, '_pastebinfile'):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue