click icon indicating copy to clipboard operation
click copied to clipboard

running tests in parallel with `tox p` fails

Open davidism opened this issue 7 months ago • 4 comments

Running tests in parallel with tox p fails, meaning I have to run all local test envs serially right now. It seems that the detected terminal environment is different in parallel mode, causing the pager tests to fail.

FAILED tests/test_utils.py::test_echo_via_pager[test0-cat] - AssertionError: Unexpected pager output in test case 'Plain string argument'

davidism avatar May 11 '25 13:05 davidism

Shouldn't it fail? Don't some test s use click's testing which is not thread safe.

Rowlando13 avatar May 12 '25 03:05 Rowlando13

It worked until the changes to the pager, and only fail on the pager test. I made sure everything ran correctly with tox p in all projects, it makes pre-checking a PR way faster.

davidism avatar May 12 '25 04:05 davidism

I agree. What did you do? I was just planning on looking some tests

Rowlando13 avatar May 12 '25 04:05 Rowlando13

There are multiple instances of this:

def test_file_args(runner):
    @click.command()
    @click.argument("input", type=click.File("rb"))
    @click.argument("output", type=click.File("wb"))
    def inout(input, output):
        while True:
            chunk = input.read(1024)
            if not chunk:
                break
            output.write(chunk)

    with runner.isolated_filesystem():
        result = runner.invoke(inout, ["-", "hello.txt"], input="Hey!")
        assert result.output == ""
        assert result.exit_code == 0
        with open("hello.txt", "rb") as f:
            assert f.read() == b"Hey!"

        result = runner.invoke(inout, ["hello.txt", "-"])
        assert result.output == "Hey!"
        assert result.exit_code == 0

Seems like the isolated_filesystem() would not be thread safe.

Rowlando13 avatar May 12 '25 04:05 Rowlando13