Skip to content

--log-file should create subdirectories #7467

@nicoddemus

Description

@nicoddemus

If you provide a path with a subdirectory, which does not exist, it crashes with.
For example execute pytest --log-file=subtest/test.log produces something like this:
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory: '/tmp/test/subtest/test.log'

Maybe someone want to add something like this

dirname = os.path.dirname(os.path.abspath(logfile))
if not os.path.isdir(dirname):
    os.makedirs(dirname)

However, there is the possibility to say that someone is not supposed to pass a directory path there.

Originally posted by @Hardy7cc in #7350 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorplugin: loggingrelated to the logging builtin plugintype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions