Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jan 24, 2020
1 parent 7d63cc8 commit d5cf0a0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions testing/code/test_excinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,21 +775,26 @@ def entry():
)
excinfo = pytest.raises(ValueError, mod.entry)

p = FormattedExcinfo(abspath=True)
p = FormattedExcinfo(abspath=False)

raised = 0

orig_getcwd = os.getcwd

def raiseos():
nonlocal raised
raised += 1
__import__("traceback").print_stack(file=sys.stdout)
raise OSError(2, "custom_oserror")
if sys._getframe().f_back.f_code.co_name == "checked_call":
# Only raise expected calls, but not via inspect for
# py38-windows.
raised += 1
raise OSError(2, "custom_oserror")
return orig_getcwd()

monkeypatch.setattr(os, "getcwd", raiseos)
assert p._makepath(__file__) == __file__
assert not raised, raised
assert raised == 1
p.repr_traceback(excinfo)
assert not raised, raised # triggered via windows-py38 only
assert raised == 3

def test_repr_excinfo_addouterr(self, importasmod, tw_mock):
mod = importasmod(
Expand Down

0 comments on commit d5cf0a0

Please sign in to comment.