commit 91844fbf0b912ca5db80c07653fc47923a52aed3 Author: juga0 juga@riseup.net Date: Sun Jun 10 14:31:50 2018 +0000
Recover datadir fixture needed for v3bwfile tests --- tests/unit/conftest.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index bb9f8e3..c9002eb 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -27,6 +27,29 @@ class _PseudoArguments(argparse.Namespace): setattr(self, key, kw[key])
+@pytest.fixture() +def datadir(request): + """ get, read, open test files from the "data" directory. """ + class D: + def __init__(self, basepath): + self.basepath = basepath + + def open(self, name, mode="r"): + return self.basepath.join(name).open(mode) + + def join(self, name): + return self.basepath.join(name).strpath + + def read(self, name): + with self.open(name, "r") as f: + return f.read() + + def readlines(self, name): + with self.open(name, "r") as f: + return f.readlines() + return D(request.fspath.dirpath("data")) + + @pytest.fixture(scope='session') def parser(): return create_parser()
tor-commits@lists.torproject.org