summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorAlex Chan <alex@alexwlchan.net>2016-10-24 16:34:41 +0100
committerHynek Schlawack <hs@ox.cx>2016-10-24 17:34:41 +0200
commit6b69c55372a390ca350fd6d2749452ffe3f55049 (patch)
tree2eda52e47b788db8f0dfa2bf5609bd2717d87417 /tests/conftest.py
parent29add1dc54122fd15d712a86bf305ab9c2ef8bc6 (diff)
downloadpyopenssl-git-6b69c55372a390ca350fd6d2749452ffe3f55049.tar.gz
Convert test_rand to use pytest-style tests (#563)
Fix up the assert helpers, subclass form `object` rather than test case, and use parametrization where appropriate. One helper method on the original `TestCase` was the ability to create temporary directories that were cleaned up at the end of the test -- now we use a pytest fixture instead: http://doc.pytest.org/en/latest/tmpdir.html Addresses #340.
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 5a9954f..366624e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,6 +1,10 @@
# Copyright (c) The pyOpenSSL developers
# See LICENSE for details.
+from tempfile import mktemp
+
+import pytest
+
def pytest_report_header(config):
import OpenSSL.SSL
@@ -10,3 +14,13 @@ def pytest_report_header(config):
openssl=OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION),
cryptography=cryptography.__version__
)
+
+
+@pytest.fixture
+def tmpfile(tmpdir):
+ """
+ Return UTF-8-encoded bytes of a path to a tmp file.
+
+ The file will be cleaned up after the test run.
+ """
+ return mktemp(dir=tmpdir.dirname).encode("utf-8")