blob: a89510c6ef0013392398b725ea9c5c14da275f69 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
--- contrib/python/pytest-localserver/py3/pytest_localserver/https.py (index)
+++ contrib/python/pytest-localserver/py3/pytest_localserver/https.py (working tree)
@@ -10,1 +10,1 @@ import os.path
-DEFAULT_CERTIFICATE = os.path.join(os.path.abspath(os.path.dirname(__file__)), "server.pem")
+DEFAULT_CERTIFICATE = os.path.join(os.getcwd(), "server.pem")
--- contrib/python/pytest-localserver/py3/pytest_localserver/plugin.py (index)
+++ contrib/python/pytest-localserver/py3/pytest_localserver/plugin.py (working tree)
@@ -4,6 +4,9 @@
#
# This program is release under the MIT license. You can find the full text of
# the license in the LICENSE file.
+import os
+import pkgutil
+
import pytest
@@ -62,11 +65,15 @@ def httpsserver(request):
SSL encryption.
"""
from pytest_localserver import https
-
- server = https.SecureContentServer()
- server.start()
- request.addfinalizer(server.stop)
- return server
+ try:
+ with open(https.DEFAULT_CERTIFICATE, 'wb') as f:
+ f.write(pkgutil.get_data('pytest_localserver', 'server.pem'))
+ server = https.SecureContentServer()
+ server.start()
+ request.addfinalizer(server.stop)
+ yield server
+ finally:
+ os.remove(https.DEFAULT_CERTIFICATE)
@pytest.fixture
|