Skip to content

Add test for os.renames - #159657

Open
ste1hi wants to merge 4 commits into
python:mainfrom
ste1hi:my-new-test
Open

ste1hi wants to merge 4 commits into
python:mainfrom
ste1hi:my-new-test

Conversation

@ste1hi

@ste1hi ste1hi commented Oct 18, 2026

Copy link
Copy Markdown

Inprove random.sample test. Add tests for when the items in the list are not integers.
Add test for os.rename function.

@ste1hi
ste1hi requested a review from rhettinger as a code owner October 18, 2026 02:52
@bedevere-app bedevere-app Bot added awaiting review tests Tests in the Lib/test dir labels Oct 18, 2026
@bedevere-app

bedevere-app Bot commented Oct 18, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz picnixz 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.

I don't think the tests for random are relevant. It's a garbage-in/garbage-out case. For os.renames, it makes sense (and I'm surprised we didn't have a test!)

@python-cla-bot

python-cla-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@ste1hi

ste1hi commented Oct 19, 2026 •

Copy link
Copy Markdown
Author

I removed the test for random.sample

@StanFromIreland StanFromIreland added the AI-needs-explanation AI-assisted work that needs further explanation and follow up from the contributor label Oct 31, 2026
@bedevere-app

bedevere-app Bot commented Oct 31, 2026

Copy link
Copy Markdown

Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors.

This contribution appears to have been authored with AI assistance. Please explain your contribution in your own words and describe how you checked its correctness.

Please read our guidelines for using AI tools.

@picnixz

picnixz commented Oct 31, 2026

Copy link
Copy Markdown
Member

@StanFromIreland This PR doesn't look like AI I guess?

@StanFromIreland

Copy link
Copy Markdown
Member

I suppose, it's hard to tell sometimes.

@picnixz picnixz changed the title Improve test for random.sample and os.renames Add test for os.renames Oct 31, 2026
@ste1hi

ste1hi commented Oct 31, 2026 •

Copy link
Copy Markdown
Author

I really did NOT use any AI assistant. Btw, I think there is no need to use AI for this simple case.

Explanation

I made a file named test in old_dir directory. Then I used os.renames to move this file to new_dir/test. Finally, I checked if the old_dir and old file test had been removed and new directory had been created.

Just curious, I want to know why you think I used AI assistant and how can I prove that I have not used AI assitant.

@StanFromIreland

Copy link
Copy Markdown
Member

That's fine, I'm sorry I didn't intend it as an insult or such thing. What I am curious about however, is how you checked coverage? What are the statistics before/after?

@picnixz

picnixz commented Oct 31, 2026

Copy link
Copy Markdown
Member

I think the coverage checking is simple using coverage.py. FTR, we don't even test os.renames at all in the file (i did a Crtl+F of os.renames itself)

@ste1hi

ste1hi commented Oct 31, 2026 •

Copy link
Copy Markdown
Author
9b27cd45-4594-4ffc-aba2-e99ebaa23f10 ec9efc54-c26c-4104-abbb-a02341c425c0

before is 51%, and after is 52%
As you can see, it's really a simple and small change.

@picnixz picnixz removed the AI-needs-explanation AI-assisted work that needs further explanation and follow up from the contributor label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants