diff options
author | Alex Chan <alex@alexwlchan.net> | 2016-10-24 16:34:41 +0100 |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2016-10-24 17:34:41 +0200 |
commit | 6b69c55372a390ca350fd6d2749452ffe3f55049 (patch) | |
tree | 2eda52e47b788db8f0dfa2bf5609bd2717d87417 /tests/conftest.py | |
parent | 29add1dc54122fd15d712a86bf305ab9c2ef8bc6 (diff) | |
download | pyopenssl-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.py | 14 |
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") |