Skip to content

Using TEST_OUTPUT_FILE_NAME with Django does not create intermediate folders specified in TEST_OUTPUT_DIR #146

@rubendura

Description

@rubendura

Title is self descriptive.
I am using unittest-xml-reporting with Django specifying both TEST_OUTPUT_DIR and TEST_OUTPUT_FILE_NAME.

According to the README for the TEST_OUTPUT_DIR setting: " If the directory couldn't be found, the test runner will try to create it before generate the XML files."
Also for TEST_OUTPUT_FILE_NAME: "Tells the test runner to output a single XML report with this filename under os.path.join(TEST_OUTPUT_DIR, TEST_OUTPUT_FILE_NAME)".

That implies that using both settings is allowed and intermediate folders will be created.
The problem is that intermediate folders will be created using os.makedirs in xmlrunner/result.py:451 if test_runner.output is a string, but when using TEST_OUTPUT_FILE_NAME test_runner.output is a file object opened in xmlrunner.extra.djangotestrunner.py:35. That line fails if intermediate folders do not exist.

I guess the simplest solution is to also run os.makedirs before the context manager opening the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions