Commit a1ac2a45 authored by Kirill Smelkov's avatar Kirill Smelkov

golang: tests: Fix Pytest integration wrt python3-dbg

There, with pytest 6.0.x, pytest emits its internal deprecation warning
(the usage of deprecated attribute is inside pytest):

    .../_pytest/compat.py:340: PytestDeprecationWarning: The TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.
    See https://docs.pytest.org/en/stable/deprecations.html#terminalreporter-writer for more information.
      return getattr(object, name, default)

Which leads to test_defer_excchain_dump_pytest failure since this test
verifies stderr to be empty:

        def test_defer_excchain_dump_pytest():
            tbok = readfile(dir_testprog + "/golang_test_defer_excchain.txt-pytest")
            retcode, stdout, stderr = _pyrun(["-m", "pytest", "-o", "python_functions=main",
                                        "--tb=short", "golang_test_defer_excchain.py"],
                                        cwd=dir_testprog, stdout=PIPE, stderr=PIPE)
            assert retcode != 0, (stdout, stderr)
    >       assert stderr == b""
    E       AssertionError: assert b'/home/kirr/...e, default)\n' == b''
    E         Full diff:
    E         - b''
    E         + (
    E         +  b'/home/kirr/src/tools/go/py3dbg.venv/lib/python3.8/site-packages/_pytest/comp'
    E         +  b'at.py:340: PytestDeprecationWarning: The TerminalReporter.writer attribute i'
    E         +  b's deprecated, use TerminalReporter._tw instead at your own risk.\nSee htt'
    E         +  b'ps://docs.pytest.org/en/stable/deprecations.html#terminalreporter-writer for'...
    E
    E         ...Full output truncated (3 lines hidden), use '-vv' to show

-> Fix it by not letting spawned pytest to emit deprecation warnings in that test.
parent a0016938
......@@ -1670,7 +1670,10 @@ def test_defer_excchain_dump_ipython():
# ----//---- (pytest)
def test_defer_excchain_dump_pytest():
tbok = readfile(dir_testprog + "/golang_test_defer_excchain.txt-pytest")
retcode, stdout, stderr = _pyrun(["-m", "pytest", "-o", "python_functions=main",
retcode, stdout, stderr = _pyrun([
# don't let pytest emit internal deprecation warnings to stderr
"-W", "ignore::DeprecationWarning",
"-m", "pytest", "-o", "python_functions=main",
"--tb=short", "golang_test_defer_excchain.py"],
cwd=dir_testprog, stdout=PIPE, stderr=PIPE)
assert retcode != 0, (stdout, stderr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment