Skip to content

Regression in testdir.makefile(), from pytester rewrite #8192

@Zac-HD

Description

@Zac-HD
def test_regression_demo(testdir):
    testdir.makefile("tests.py", "# python file contents\n")

This works under pytest 6.1.2, but fails under 6.2.x - i.e. following #7854 - with

____________________________ test_regression_demo _____________________________
Traceback (most recent call last):
  File "t.py", line 2, in test_regression_demo
    testdir.makefile("tests.py", "# python file contents/n")
  File "site-packages/_pytest/pytester.py", line 1547, in makefile
    return py.path.local(str(self._pytester.makefile(ext, *args, **kwargs)))
  File "site-packages/_pytest/pytester.py", line 788, in makefile
    return self._makefile(ext, args, kwargs)
  File "site-packages/_pytest/pytester.py", line 756, in _makefile
    p = self.path.joinpath(basename).with_suffix(ext)
  File "lib/pathlib.py", line 889, in with_suffix
    raise ValueError("Invalid suffix %r" % (suffix))
ValueError: Invalid suffix 'tests.py'

I think the new behaviour for pytester is fine, but the compatibility layer seems to need a little work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortopic: fixturesanything involving fixtures directly or indirectlytype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions