Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop unintentionally creating a folder during tests on Windows #1188

Merged
merged 3 commits into from
Apr 17, 2023

Conversation

rmartin16
Copy link
Member

@rmartin16 rmartin16 commented Apr 16, 2023

Changes

  • Testing failure from writing the log file was actually depending on the call to mkdir() to fail.
    • This was assuming creating a root directory would fail...and it does on non-Windows systems.
    • On Windows, the call to create the root directory succeeds....but writing the logfile then fails.
Failed to save log to \a-path-that-will-cause-an-OSError...\logs\briefcase.2023_04_16-11_10_46.dev.log: [WinError 3] The system cannot find the path specified: '\\a-path-that-will-cause-an-OSError...\\logs'
  • Instead of depending on actual filesystem interaction to test failure while writing the log file, this updates the test to mock the filesystem error when the file write occurs.
  • This also introduces a test case for failing to create the directory....although, it's admittedly a little obtuse and probably fragile.

Reference

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Looks good; one suggested cleanup/reversion around the autouse on the now fixture.

from briefcase.exceptions import BriefcaseError

TRACEBACK_HEADER = "Traceback (most recent call last)"
EXTRA_HEADER = "Extra information:"


@pytest.fixture
@pytest.fixture(autouse=True)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a big fan of autouse - outside of "whole of test suite" configuration setup, I find explicit is better than implicit. For the sake of including a now fixture in a handful of tests, which makes it clear that "this test has a specific time interpretation".

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fair; also removed it from Windows SDK tests.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Looks good!

@freakboy3742 freakboy3742 merged commit 5c83de4 into beeware:main Apr 17, 2023
@rmartin16 rmartin16 deleted the win-test-dir branch April 17, 2023 05:02
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.

Running test suite leaves a top level folder "a-path-that-will-cause-an-OSError"
2 participants