Skip to content

Unit test test_json_exporter doesn't work on Windows #114

@laurent-laporte-pro

Description

@laurent-laporte-pro

The unit test tests.test_jsonexporter.test_json_exporter doesn't work on Windows.

In the fragment bellow:

with NamedTemporaryFile(mode="w+") as ref:
    with NamedTemporaryFile(mode="w+") as gen:
        ref.write("\n".join(lines))
        exporter.write(root, gen)
        assert filecmp.cmp(ref.name, gen.name)

The filecmp.cmp function failed because the files are still opened.

The exception is:

Traceback (most recent call last):
  ...
  File "C:\Program Files\Python38\lib\filecmp.py", line 75, in _do_cmp
    with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2:
PermissionError: [Errno 13] Permission denied: 'C:\\...\\AppData\\Local\\Temp\\tmpgr3lyx2m'

The solution is to close the files before comparison.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions