[Tests] Place logfiles from py.test run in _pytest_temp

This commit is contained in:
bendikro 2016-05-11 01:49:29 +02:00 committed by Calum Lind
parent 6971e08b0d
commit fd9e68e7e7
2 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,6 @@
import os.path
import pytest
from twisted.internet import defer
from twisted.internet.error import CannotListenError
@ -29,6 +32,15 @@ class DaemonBase(object):
if logfile == "":
logfile = "daemon_%s.log" % self.id()
# We are running py.test
if hasattr(pytest, "config"):
# Put log file in the py.test --basetemp argument
basetemp = pytest.config.option.basetemp
if basetemp:
if not os.path.exists(basetemp):
os.makedirs(basetemp)
logfile = os.path.join(basetemp, logfile)
for dummy in range(port_range):
try:
d, self.core = common.start_core(listen_port=self.listen_port, logfile=logfile,

12
tox.ini
View File

@ -37,7 +37,7 @@ python_functions = test_
norecursedirs = .tox .git dist build
pep8maxlinelength = 120
whitelist_externals= {[testenv]whitelist_externals}
commands = py.test deluge
commands = py.test --basetemp=_pytest_temp deluge
##############
@ -47,13 +47,13 @@ commands = py.test deluge
[testenv:pydef]
commands =
python -c "import libtorrent as lt; print lt.version"
py.test -v -s -m "not (todo or gtkui)" deluge/tests
py.test -v --basetemp=_pytest_temp -s -m "not (todo or gtkui)" deluge/tests
[testenv:pygtkui]
commands = py.test -v -s -m "gtkui" deluge/tests
commands = py.test -v --basetemp=_pytest_temp -s -m "gtkui" deluge/tests
[testenv:todo]
commands = py.test -v -s -m "todo" deluge/tests
commands = py.test -v --basetemp=_pytest_temp -s -m "todo" deluge/tests
[testenv:trial]
setenv = {[testenv]setenv}:{env:PWD}/deluge/tests
@ -64,13 +64,13 @@ commands = trial --reporter=deluge-reporter deluge/tests
setenv = PYTHONPATH = {env:PWD}:{env:PWD}/deluge/plugins
commands =
python setup.py build_plugins --develop --install-dir={env:PWD}/deluge/plugins/
py.test -v -s -m "not gtkui" deluge/plugins
py.test -v --basetemp=_pytest_temp -s -m "not gtkui" deluge/plugins
[testenv:pluginsgtkui]
setenv = PYTHONPATH = {env:PWD}:{env:PWD}/deluge/plugins
commands =
python setup.py build_plugins --develop --install-dir={env:PWD}/deluge/plugins/
py.test -v -s deluge/plugins
py.test -v --basetemp=_pytest_temp -s deluge/plugins
[testenv:py26]
basepython = python2.6