diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index ce1c8ea1c..245b35d14 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -53,6 +53,10 @@ def pytest_addoption(parser): ), ) + parser.addini( + "pytester_example_dir", help="directory to take the pytester example files from" + ) + def pytest_configure(config): if config.getvalue("lsof"): @@ -628,6 +632,11 @@ class Testdir(object): p.ensure("__init__.py") return p + def copy_example(self, name): + example_dir = self.request.config.getini("pytester_example_dir") + example_path = self.request.config.rootdir.join(example_dir, name) + example_path.copy(self.tmpdir.join(example_path.basename)) + Session = Session def getnode(self, config, arg): diff --git a/tox.ini b/tox.ini index e0ef2dccc..98abe28f3 100644 --- a/tox.ini +++ b/tox.ini @@ -204,7 +204,7 @@ filterwarnings = ignore:.*type argument to addoption.*:DeprecationWarning # produced by python >=3.5 on execnet (pytest-xdist) ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning - +pytester_example_dir = testing/example_scripts [flake8] max-line-length = 120 ignore = E203,W503