зеркало из https://github.com/openwpm/OpenWPM.git
Use py.test tmpdir fixture instead of mkdtemp.
py.test tmpdir directory names are more convenient. We add a property to access the tmpdir fixture from get_test_config.
This commit is contained in:
Родитель
16d67cd803
Коммит
c75a7f7906
Двоичные данные
automation/Extension/firefox/openwpm.xpi
Двоичные данные
automation/Extension/firefox/openwpm.xpi
Двоичный файл не отображается.
|
@ -1,7 +1,6 @@
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import utilities
|
import utilities
|
||||||
import pytest
|
import pytest
|
||||||
from tempfile import mkdtemp
|
|
||||||
import commands
|
import commands
|
||||||
from ..automation import TaskManager
|
from ..automation import TaskManager
|
||||||
|
|
||||||
|
@ -9,6 +8,15 @@ from ..automation import TaskManager
|
||||||
class OpenWPMTest(object):
|
class OpenWPMTest(object):
|
||||||
NUM_BROWSERS = 1
|
NUM_BROWSERS = 1
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def set_tmpdir(self, tmpdir):
|
||||||
|
"""Create a tmpdir fixture to be used in `get_test_config`.
|
||||||
|
|
||||||
|
Based on:
|
||||||
|
https://mail.python.org/pipermail/pytest-dev/2014-April/002484.html
|
||||||
|
"""
|
||||||
|
self.tmpdir = str(tmpdir)
|
||||||
|
|
||||||
def visit(self, page_url, data_dir="", sleep_after=0):
|
def visit(self, page_url, data_dir="", sleep_after=0):
|
||||||
"""Visit a test page with the given parameters."""
|
"""Visit a test page with the given parameters."""
|
||||||
manager_params, browser_params = self.get_config(data_dir)
|
manager_params, browser_params = self.get_config(data_dir)
|
||||||
|
@ -23,7 +31,7 @@ class OpenWPMTest(object):
|
||||||
num_browsers=NUM_BROWSERS):
|
num_browsers=NUM_BROWSERS):
|
||||||
"""Load and return the default test parameters."""
|
"""Load and return the default test parameters."""
|
||||||
if not data_dir:
|
if not data_dir:
|
||||||
data_dir = mkdtemp()
|
data_dir = self.tmpdir
|
||||||
manager_params, browser_params = TaskManager.\
|
manager_params, browser_params = TaskManager.\
|
||||||
load_default_params(num_browsers)
|
load_default_params(num_browsers)
|
||||||
manager_params['data_directory'] = data_dir
|
manager_params['data_directory'] = data_dir
|
||||||
|
|
Загрузка…
Ссылка в новой задаче