diff options
author | Anthony Sottile <asottile@umich.edu> | 2017-12-26 19:47:26 -0800 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2018-01-09 12:44:10 -0800 |
commit | bd1d17e8de30f6d52f9c4b61df4c6403f8f4f61c (patch) | |
tree | d837309ccb52e32f1cbf0243f3f8d55712ca9b38 /testing/code | |
parent | 962aede2904592b206ae8e4e3fe0c749fd178a45 (diff) | |
download | pytest-bd1d17e8de30f6d52f9c4b61df4c6403f8f4f61c.tar.gz |
Replace py.std with stdlib imports
Diffstat (limited to 'testing/code')
-rw-r--r-- | testing/code/test_excinfo.py | 18 | ||||
-rw-r--r-- | testing/code/test_source.py | 8 |
2 files changed, 14 insertions, 12 deletions
diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 58b1b1b67..6b4adf001 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -2,6 +2,8 @@ from __future__ import absolute_import, division, print_function import operator +import os +import sys import _pytest import py import pytest @@ -472,7 +474,7 @@ class TestFormattedExcinfo(object): excinfo = _pytest._code.ExceptionInfo() repr = pr.repr_excinfo(excinfo) assert repr.reprtraceback.reprentries[1].lines[0] == "> ???" - if py.std.sys.version_info[0] >= 3: + if sys.version_info[0] >= 3: assert repr.chain[0][0].reprentries[1].lines[0] == "> ???" def test_repr_many_line_source_not_existing(self): @@ -487,7 +489,7 @@ raise ValueError() excinfo = _pytest._code.ExceptionInfo() repr = pr.repr_excinfo(excinfo) assert repr.reprtraceback.reprentries[1].lines[0] == "> ???" - if py.std.sys.version_info[0] >= 3: + if sys.version_info[0] >= 3: assert repr.chain[0][0].reprentries[1].lines[0] == "> ???" def test_repr_source_failing_fullsource(self): @@ -545,13 +547,13 @@ raise ValueError() fail = IOError() repr = pr.repr_excinfo(excinfo) assert repr.reprtraceback.reprentries[0].lines[0] == "> ???" - if py.std.sys.version_info[0] >= 3: + if sys.version_info[0] >= 3: assert repr.chain[0][0].reprentries[0].lines[0] == "> ???" fail = py.error.ENOENT # noqa repr = pr.repr_excinfo(excinfo) assert repr.reprtraceback.reprentries[0].lines[0] == "> ???" - if py.std.sys.version_info[0] >= 3: + if sys.version_info[0] >= 3: assert repr.chain[0][0].reprentries[0].lines[0] == "> ???" def test_repr_local(self): @@ -738,7 +740,7 @@ raise ValueError() repr = p.repr_excinfo(excinfo) assert repr.reprtraceback assert len(repr.reprtraceback.reprentries) == len(reprtb.reprentries) - if py.std.sys.version_info[0] >= 3: + if sys.version_info[0] >= 3: assert repr.chain[0][0] assert len(repr.chain[0][0].reprentries) == len(reprtb.reprentries) assert repr.reprcrash.path.endswith("mod.py") @@ -758,7 +760,7 @@ raise ValueError() def raiseos(): raise OSError(2) - monkeypatch.setattr(py.std.os, 'getcwd', raiseos) + monkeypatch.setattr(os, 'getcwd', raiseos) assert p._makepath(__file__) == __file__ p.repr_traceback(excinfo) @@ -816,10 +818,10 @@ raise ValueError() for style in ("short", "long", "no"): for showlocals in (True, False): repr = excinfo.getrepr(style=style, showlocals=showlocals) - if py.std.sys.version_info[0] < 3: + if sys.version_info[0] < 3: assert isinstance(repr, ReprExceptionInfo) assert repr.reprtraceback.style == style - if py.std.sys.version_info[0] >= 3: + if sys.version_info[0] >= 3: assert isinstance(repr, ExceptionChainRepr) for repr in repr.chain: assert repr[0].style == style diff --git a/testing/code/test_source.py b/testing/code/test_source.py index fcce3fa96..ee731ed4f 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -2,6 +2,7 @@ # disable flake check on this file because some constructs are strange # or redundant on purpose and can't be disable on a line-by-line basis from __future__ import absolute_import, division, print_function +import inspect import sys import _pytest._code @@ -187,9 +188,9 @@ class TestSourceParsingAndCompiling(object): def f(): raise ValueError() """) - source1 = py.std.inspect.getsource(co1) + source1 = inspect.getsource(co1) assert 'KeyError' in source1 - source2 = py.std.inspect.getsource(co2) + source2 = inspect.getsource(co2) assert 'ValueError' in source2 def test_getstatement(self): @@ -373,7 +374,6 @@ def test_deindent(): c = '''while True: pass ''' - import inspect lines = deindent(inspect.getsource(f).splitlines()) assert lines == ["def f():", " c = '''while True:", " pass", "'''"] @@ -461,7 +461,7 @@ def test_getfslineno(): fspath, lineno = getfslineno(A) - _, A_lineno = py.std.inspect.findsource(A) + _, A_lineno = inspect.findsource(A) assert fspath.basename == "test_source.py" assert lineno == A_lineno |