Skip to content

Create test files in temporary directories#578

Merged
mferrera merged 1 commit intoequinor:mainfrom
mferrera:tmpdir-tests
Jul 18, 2023
Merged

Create test files in temporary directories#578
mferrera merged 1 commit intoequinor:mainfrom
mferrera:tmpdir-tests

Conversation

@mferrera
Copy link
Copy Markdown
Collaborator

@mferrera mferrera commented Jul 18, 2023

A few tests left test files in the root directory after a test run. This could cause race conditions in some cases with pytest-xdist and tests should not leave junk files in the root directory at any rate.

Resolves #563

@mferrera mferrera requested a review from alifbe July 18, 2023 09:30
@alifbe
Copy link
Copy Markdown
Collaborator

alifbe commented Jul 18, 2023

@mferrera Nice.....I did a quick search and found a few other places as well which are not typically run in the local setup, but I think is run within komodo testing. Do you think it's worth to update as well?

Path("FOOBAR.DATA").write_text("--Empty", encoding="utf8")

Path("FOO.DATA").write_text(str(resmodel), encoding="utf8")

A few tests left test files in the root directory after a test run.
This could cause race conditions in some cases with pytest-xdist and
tests should not leave junk files in the root directory at any rate.
@mferrera
Copy link
Copy Markdown
Collaborator Author

Good catch! The ones you highlighted are actually okay -- they use a fixture that changes dir for them (former case) or call the simulator function after changing dir in the test function (latter case). But I found a few cases where the dir change didn't happen or otherwise left files around. I don't seem to find any more files in the root dir when run with simulators as well now.

@alifbe
Copy link
Copy Markdown
Collaborator

alifbe commented Jul 18, 2023

Good catch! The ones you highlighted are actually okay -- they use a fixture that changes dir for them (former case) or call the simulator function after changing dir in the test function (latter case). But I found a few cases where the dir change didn't happen or otherwise left files around. I don't seem to find any more files in the root dir when run with simulators as well now.

Good to know 😄

Copy link
Copy Markdown
Collaborator

@alifbe alifbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@mferrera mferrera merged commit d53630a into equinor:main Jul 18, 2023
@mferrera mferrera deleted the tmpdir-tests branch July 18, 2023 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run tests in tmp dirs when files are written

2 participants