Skip to content

Commit e7d25ee

Browse files
committed
Use six.wraps in test decorators to allow pytest fixtures
pytest-dev/pytest#2782
1 parent b2fe7be commit e7d25ee

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

test/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import warnings
22
import sys
33
import errno
4-
import functools
54
import logging
65
import socket
76
import ssl
@@ -56,7 +55,7 @@ def setUp():
5655
def onlyPy279OrNewer(test):
5756
"""Skips this test unless you are on Python 2.7.9 or later."""
5857

59-
@functools.wraps(test)
58+
@six.wraps(test)
6059
def wrapper(*args, **kwargs):
6160
msg = "{name} requires Python 2.7.9+ to run".format(name=test.__name__)
6261
if sys.version_info < (2, 7, 9):
@@ -69,7 +68,7 @@ def wrapper(*args, **kwargs):
6968
def onlyPy2(test):
7069
"""Skips this test unless you are on Python 2.x"""
7170

72-
@functools.wraps(test)
71+
@six.wraps(test)
7372
def wrapper(*args, **kwargs):
7473
msg = "{name} requires Python 2.x to run".format(name=test.__name__)
7574
if not six.PY2:
@@ -82,7 +81,7 @@ def wrapper(*args, **kwargs):
8281
def onlyPy3(test):
8382
"""Skips this test unless you are on Python3.x"""
8483

85-
@functools.wraps(test)
84+
@six.wraps(test)
8685
def wrapper(*args, **kwargs):
8786
msg = "{name} requires Python3.x to run".format(name=test.__name__)
8887
if six.PY2:
@@ -105,7 +104,7 @@ def notBrotlipy():
105104
def notSecureTransport(test):
106105
"""Skips this test when SecureTransport is in use."""
107106

108-
@functools.wraps(test)
107+
@six.wraps(test)
109108
def wrapper(*args, **kwargs):
110109
msg = "{name} does not run with SecureTransport".format(name=test.__name__)
111110
if ssl_.IS_SECURETRANSPORT:
@@ -118,7 +117,7 @@ def wrapper(*args, **kwargs):
118117
def notOpenSSL098(test):
119118
"""Skips this test for Python 3.4 and 3.5 macOS python.org distributions"""
120119

121-
@functools.wraps(test)
120+
@six.wraps(test)
122121
def wrapper(*args, **kwargs):
123122
is_stdlib_ssl = not ssl_.IS_SECURETRANSPORT and not ssl_.IS_PYOPENSSL
124123
if is_stdlib_ssl and ssl.OPENSSL_VERSION == "OpenSSL 0.9.8zh 14 Jan 2016":
@@ -153,7 +152,7 @@ def _has_route():
153152
else:
154153
raise
155154

156-
@functools.wraps(test)
155+
@six.wraps(test)
157156
def wrapper(*args, **kwargs):
158157
global _requires_network_has_route
159158

@@ -172,7 +171,7 @@ def wrapper(*args, **kwargs):
172171

173172

174173
def requires_ssl_context_keyfile_password(test):
175-
@functools.wraps(test)
174+
@six.wraps(test)
176175
def wrapper(*args, **kwargs):
177176
if (
178177
not ssl_.IS_PYOPENSSL and sys.version_info < (2, 7, 9)
@@ -194,7 +193,7 @@ def fails_on_travis_gce(test):
194193
https://github.com/urllib3/urllib3/pull/1475#issuecomment-440788064
195194
"""
196195

197-
@functools.wraps(test)
196+
@six.wraps(test)
198197
def wrapper(*args, **kwargs):
199198
if os.environ.get("TRAVIS_INFRA") in ("gce", "unknown"):
200199
pytest.xfail("%s is expected to fail on Travis GCE builds" % test.__name__)

0 commit comments

Comments
 (0)