fix python2.5 issues
This commit is contained in:
parent
5aa5b9748d
commit
3d00cd35fc
|
@ -1,7 +1,6 @@
|
||||||
""" monkeypatching and mocking functionality. """
|
""" monkeypatching and mocking functionality. """
|
||||||
|
|
||||||
import os, sys, inspect
|
import os, sys
|
||||||
import pytest
|
|
||||||
|
|
||||||
def pytest_funcarg__monkeypatch(request):
|
def pytest_funcarg__monkeypatch(request):
|
||||||
"""The returned ``monkeypatch`` funcarg provides these
|
"""The returned ``monkeypatch`` funcarg provides these
|
||||||
|
@ -28,6 +27,7 @@ def pytest_funcarg__monkeypatch(request):
|
||||||
|
|
||||||
|
|
||||||
def derive_importpath(import_path):
|
def derive_importpath(import_path):
|
||||||
|
import pytest
|
||||||
if not isinstance(import_path, str) or "." not in import_path:
|
if not isinstance(import_path, str) or "." not in import_path:
|
||||||
raise TypeError("must be absolute import path string, not %r" %
|
raise TypeError("must be absolute import path string, not %r" %
|
||||||
(import_path,))
|
(import_path,))
|
||||||
|
@ -82,6 +82,7 @@ class monkeypatch:
|
||||||
which means it will raise).
|
which means it will raise).
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
|
import inspect
|
||||||
|
|
||||||
if value is notset:
|
if value is notset:
|
||||||
if not isinstance(target, str):
|
if not isinstance(target, str):
|
||||||
|
|
|
@ -37,11 +37,11 @@ def pytest_configure(config):
|
||||||
# we try hard to make printing resilient against
|
# we try hard to make printing resilient against
|
||||||
# later changes on FD level. (unless capturing is off/sys)
|
# later changes on FD level. (unless capturing is off/sys)
|
||||||
stdout = sys.stdout
|
stdout = sys.stdout
|
||||||
if hasattr(os, "dup"):
|
if hasattr(os, "dup") and hasattr(stdout, "fileno"):
|
||||||
try:
|
try:
|
||||||
newstdout = py.io.dupfile(stdout, buffering=1,
|
newstdout = py.io.dupfile(stdout, buffering=1,
|
||||||
encoding=stdout.encoding)
|
encoding=stdout.encoding)
|
||||||
except ValueError:
|
except (AttributeError, ValueError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
assert stdout.encoding == newstdout.encoding
|
assert stdout.encoding == newstdout.encoding
|
||||||
|
|
Loading…
Reference in New Issue