Skip to content

basetemp should not be collected #7947

Open

Description

@graingert

when using a basetemp in the test collection source directory and adding valid, failing pytests to it the tests are collected before the basetemp directory is ensure_reset_dir'd

related to #7940

def test_basetemp_not_collected(testdir):
    testdir.makepyfile(
        r"""
        def test(tmp_path):
            (tmp_path / "test_fail.py").write_text(
                "def test_fail():\n     assert False"
            )
        """
    )
    assert testdir.runpytest("--basetemp=tmp").ret == 0
    # running a second time and ensure we don't crash
    assert testdir.runpytest("--basetemp=tmp").ret == 0

Activity

  1. graingert commented on Oct 26, 2020

    @graingert
    MemberAuthor

    @RonnyPfannschmidt should collect call TempPathFactory.getbasetemp (and rm_rf the tmp dir) or should it be excluded by default?

  2. graingert commented on Oct 26, 2020

    @graingert
    MemberAuthor
    def test_basetemp_not_collected(testdir):
        testdir.makepyfile(
            r"""
            def test(tmp_path):
                (tmp_path / "test_fail.py").write_text(
                    "def test_fail():\n     assert False"
                )
            """
        )
        assert testdir.runpytest("--basetemp=tmp1").ret == 0
        # running a second time and ensure we don't crash
        assert testdir.runpytest("--basetemp=tmp2").ret == 0

    secondly, what should happen if the basetemp is different between runs? Should pytest clean basetemp after the run?

    should pytest add a .pytest-basetemp sentinel file for collect to ignore?

  3. RonnyPfannschmidt commented on Oct 27, 2020

    @RonnyPfannschmidt
    Member

    I'd leave ignoring basetmp to the user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions