From fd9e68e7e7fad936fe55c01ddc354c774e8d2cd6 Mon Sep 17 00:00:00 2001 From: bendikro Date: Wed, 11 May 2016 01:49:29 +0200 Subject: [PATCH] [Tests] Place logfiles from py.test run in _pytest_temp --- deluge/tests/daemon_base.py | 12 ++++++++++++ tox.ini | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py index 4940f2b12..ccfaf790d 100644 --- a/deluge/tests/daemon_base.py +++ b/deluge/tests/daemon_base.py @@ -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, diff --git a/tox.ini b/tox.ini index 6ce956b32..d137d8ded 100644 --- a/tox.ini +++ b/tox.ini @@ -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