Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better fix for TerminalReporter issue #299

Merged
merged 1 commit into from
May 14, 2020

Conversation

BeyondEvil
Copy link
Contributor

The issue with TerminalWriter in pytester is causing tests to fail.

dhalperi
dhalperi previously approved these changes May 13, 2020
testing/test_pytest_html.py Outdated Show resolved Hide resolved
@BeyondEvil
Copy link
Contributor Author

Seems like Travis is having some issues. Will try again tomorrow.

@BeyondEvil
Copy link
Contributor Author

@nicoddemus Sorry for spamming with reviewers, but this is blocking other PRs.

@@ -894,9 +887,6 @@ def test_css_invalid(self, testdir, recwarn):
assert "No such file or directory: 'style.css'" in result.stderr.str()

def test_css_invalid_no_html(self, testdir):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mark the tests to filter warnings:

@pytest.mark.filterwarnings("ignore:.*TerminalReporter.writer.*")

You might not need remove_deprecation_from_recwarn in the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it and it didn't work @nicoddemus

Maybe I'm doing something wrong?

    @pytest.mark.filterwarnings("ignore:.*TerminalReporter.writer.*")
    @pytest.mark.parametrize("colors", [(["red"]), (["green", "blue"])])
    def test_css(self, testdir, recwarn, colors):
        testdir.makepyfile("def test_pass(): pass")
        css = {}
        cssargs = []
        for color in colors:
            style = f"* {{color: {color}}}"
            path = testdir.makefile(".css", **{color: style})
            css[color] = {"style": style, "path": path}
            cssargs.extend(["--css", path])
        result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
        assert result.ret == 0
        assert len(recwarn) == 0
        for k, v in css.items():
            assert str(v["path"]) in html
            assert v["style"] in html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah unfortunately the mark is considered only for the test run, not the setup (which is where the warning is issued).

@nicoddemus
Copy link
Member

@nicoddemus Sorry for spamming with reviewers, but this is blocking other PRs.

No worries, I appreciate the ping. 👍

@BeyondEvil BeyondEvil merged commit 51f50f5 into pytest-dev:master May 14, 2020
@ssbarnea ssbarnea added the bug This issue/PR relates to a bug. label Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants