[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] Add common conftest



commit 77d639d8eee6557739037140db966ed3c48ad3d3
Author: juga0 <juga@xxxxxxxxxx>
Date:   Thu Jul 5 14:51:31 2018 +0000

    Add common conftest
---
 tests/conftest.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..1d5da5b
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,31 @@
+"""Common pytest configuration for unit and integration tests."""
+import pytest
+from sbws.util.parser import create_parser
+
+
+@pytest.fixture(scope='session')
+def parser():
+    return create_parser()
+
+
+@pytest.fixture()
+def datadir(request):
+    """get, read, open test files from the tests "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"))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits