Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 1, 2025

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
Copy link
Member Author

vstinner commented Oct 1, 2025

cc @serhiy-storchaka

filename = os_helper.TESTFN
self.addCleanup(os_helper.unlink, filename)
create_file(filename)
self.assertRaises(OSError, os.mkdir, filename)
Copy link
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
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.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

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
Copy link
Member Author

vstinner commented Oct 2, 2025

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

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 CentOS9 NoGIL Refleaks 3.x (tier-1) has failed when building commit af01b46.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1610/builds/2155) and take a look at the build logs.
  4. Check if the failure is related to this commit (af01b46) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1610/builds/2155

Failed tests:

  • test_free_threading

Test leaking resources:

  • test_free_threading: file descriptors

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 7, done.        
remote: Counting objects:  20% (1/5)        
remote: Counting objects:  40% (2/5)        
remote: Counting objects:  60% (3/5)        
remote: Counting objects:  80% (4/5)        
remote: Counting objects: 100% (5/5)        
remote: Counting objects: 100% (5/5), done.        
remote: Compressing objects:  50% (1/2)        
remote: Compressing objects: 100% (2/2)        
remote: Compressing objects: 100% (2/2), done.        
remote: Total 7 (delta 3), reused 3 (delta 3), pack-reused 2 (from 1)        
From https://github.com/python/cpython
 * branch                    main       -> FETCH_HEAD
Note: switching to 'af01b4686613ec712f803959f0dba4e34d07ae3e'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at af01b468661 gh-139322: Remove redundant `test_os.Win32ErrorTests` (#139477)
Switched to and reset branch 'main'

configure: WARNING: no system libmpdec found; falling back to pure-Python version for the decimal module

make: *** [Makefile:2487: buildbottest] Error 2

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