gh-139322: Remove redundant `test_os.Win32ErrorTests` by vstinner · Pull Request #139477 · python/cpython · GitHub
Skip to content

gh-139322: Remove redundant test_os.Win32ErrorTests#139477

Merged
vstinner merged 4 commits into
python:mainfrom
vstinner:remove_win32_error_tests
Oct 2, 2025
Merged

gh-139322: Remove redundant test_os.Win32ErrorTests#139477
vstinner merged 4 commits into
python:mainfrom
vstinner:remove_win32_error_tests

Conversation

@vstinner

@vstinner vstinner commented Oct 1, 2025

Copy link
Copy Markdown
Member

test_os OSErrorTests already covers the OSError class and is more complete than Win32ErrorTests.

test_os OSErrorTests already covers the OSError class and is more
complete than Win32ErrorTests.
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Oct 1, 2025
@picnixz picnixz changed the title gh-139322: Remove test_os Win32ErrorTests gh-139322: Remove redundant test_os.Win32ErrorTests Oct 1, 2025
@vstinner

vstinner commented Oct 1, 2025

Copy link
Copy Markdown
Member Author

Comment thread Lib/test/test_os/test_os.py Outdated
filename = os_helper.TESTFN
self.addCleanup(os_helper.unlink, filename)
create_file(filename)
self.assertRaises(OSError, os.mkdir, filename)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe test for more concrete OSError subclass? It is FileExistsError on Linux.

Also, NotADirectoryError for os.path.join(filename, 'subdir') and FileNotFoundError for os.path.join(filename, 'subdir') if filename does not exist,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let me try with FileExistsError.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. 👍

But if we add a new test, I suggest to add also tests for os.path.join(filename, 'subdir'), before and after creation of filename. AFAIK, this is not tested.

@vstinner vstinner merged commit af01b46 into python:main Oct 2, 2025
43 checks passed
@vstinner vstinner deleted the remove_win32_error_tests branch October 2, 2025 18:46
@vstinner

vstinner commented Oct 2, 2025

Copy link
Copy Markdown
Member Author

Merged. I added more tests on chdir() errors.

@bedevere-bot

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants