GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-131178: Add tests for `ftplib` command-line interface by rudy-07 · Pull Request #161080 · python/cpython

Conversation

@rudy-07

@rudy-07 rudy-07 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Add unit tests in Lib/test/test_ftplib.py covering the ftplib command-line interface (python -m ftplib):

  • Empty invocation prints usage docstring and exits with code 0.
  • Subprocess execution with test.support.script_helper.assert_python_ok.
  • Host connection and -d debugging level adjustments.
  • -l (directory listing), -d (CWD), and -p (passive mode) command parsing.
  • File retrieval (RETR).
  • -r custom netrc file error handling.

Part of gh-131178.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rudy-07
gh-131178: Add tests for ftplib command-line interface
31c2aa7
Add unit tests in Lib/test/test_ftplib.py covering the ftplib command-line interface: verifying usage message on empty invocation, subprocess invocation, host connection with debuglevel, directory and passive mode commands, file retrieval, and custom netrc file error handling.
Copilot AI balanced review requested due to automatic review settings November 1, 2026 14:23
@rudy-07
rudy-07 requested a review from giampaolo as a code owner November 1, 2026 14:23
@python-cla-bot

python-cla-bot Bot commented Nov 1, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting review type-feature A feature request or enhancement labels Nov 1, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Nov 1, 2026
Add tests for command-line interface #131178
Open
7 of 9 tasks
Copilot AI reviewed Nov 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Nov 1, 2026
@orsenthil

orsenthil commented Nov 1, 2026

Copy link
Copy Markdown
Member

Could you check the failures in the CI?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rudy-07
gh-131178: Fix requires_subprocess decorator syntax and isolate netrc…
2f1b646
… in ftplib CLI tests
@rudy-07

rudy-07 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @orsenthil,

The initial failure was caused by missing parentheses on @requires_subprocess in Lib/test/test_ftplib.py, which caused a TypeError at import time when the test runner loaded the module.

I pushed commit 2f1b646 to fix the decorator invocation to @requires_subprocess(), and also mocked netrc.netrc in the command tests to ensure hermetic execution regardless of the runner environment.

All test jobs across all platforms have now passed. Please let me know if any further changes are needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orsenthil orsenthil removed the type-feature A feature request or enhancement label Nov 1, 2026
@orsenthil
Delete Misc/NEWS.d/next/Tests/2026-11-01-19-45-00.gh-issue-131178.ftp…
35c8cfc
…lib.rst

Don't need this for the test only enhancement.
@bedevere-app

bedevere-app Bot commented Nov 1, 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Nov 1, 2026
@orsenthil orsenthil added skip news and removed type-feature A feature request or enhancement labels Nov 1, 2026
orsenthil
orsenthil approved these changes Nov 1, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Nov 1, 2026
@orsenthil orsenthil added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 1, 2026
@orsenthil
orsenthil enabled auto-merge (squash) November 1, 2026 19:56
@orsenthil
orsenthil merged commit c29f95a into python:main Nov 1, 2026
63 of 64 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

Thanks @rudy-07 for the PR, and @orsenthil for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 1, 2026
@bedevere-bot

bedevere-bot commented Nov 1, 2026

Copy link
Copy Markdown

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

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

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/1609/builds/7679) and take a look at the build logs.
  4. Check if the failure is related to this commit (c29f95a) 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/1609/builds/7679

Failed tests:

  • test_ftplib

Failed subtests:

  • test_cli_retrieve_file - test.test_ftplib.CommandLineTest.test_cli_retrieve_file

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.nogil/build/Lib/unittest/mock.py", line 1437, in patched
    return func(*newargs, **newkeywargs)
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.nogil/build/Lib/test/test_ftplib.py", line 1246, in test_cli_retrieve_file
    ftplib.test()
    ~~~~~~~~~~~^^
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.nogil/build/Lib/ftplib.py", line 968, in test
    sys.stdout.buffer.write, 1024)
    ^^^^^^^^^^^^^^^^^
AttributeError: '_io.StringIO' object has no attribute 'buffer'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Nov 1, 2026

Copy link
Copy Markdown

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

Hi! The buildbot ARM64 macOS 3.x (tier-1) has failed when building commit c29f95a.

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/725/builds/15020) and take a look at the build logs.
  4. Check if the failure is related to this commit (c29f95a) 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/725/builds/15020

Failed tests:

  • test_ftplib

Failed subtests:

  • test_cli_retrieve_file - test.test_ftplib.CommandLineTest.test_cli_retrieve_file

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/unittest/mock.py", line 1437, in patched
    return func(*newargs, **newkeywargs)
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_ftplib.py", line 1246, in test_cli_retrieve_file
    ftplib.test()
    ~~~~~~~~~~~^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/ftplib.py", line 968, in test
    sys.stdout.buffer.write, 1024)
    ^^^^^^^^^^^^^^^^^
AttributeError: '_io.StringIO' object has no attribute 'buffer'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Nov 1, 2026

Copy link
Copy Markdown

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

Hi! The buildbot ARM Raspbian 3.x (tier-3) has failed when building commit c29f95a.

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/424/builds/15603) and take a look at the build logs.
  4. Check if the failure is related to this commit (c29f95a) 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/424/builds/15603

Failed tests:

  • test_ftplib

Failed subtests:

  • test_cli_retrieve_file - test.test_ftplib.CommandLineTest.test_cli_retrieve_file

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/unittest/mock.py", line 1437, in patched
    return func(*newargs, **newkeywargs)
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/test/test_ftplib.py", line 1246, in test_cli_retrieve_file
    ftplib.test()
    ~~~~~~~~~~~^^
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/ftplib.py", line 968, in test
    sys.stdout.buffer.write, 1024)
    ^^^^^^^^^^^^^^^^^
AttributeError: '_io.StringIO' object has no attribute 'buffer'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rudy-07

rudy-07 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging! I noticed the buildbot failure in test_cli_retrieve_file caused by sys.stdout lacking a .buffer attribute under regrtest. I will open a follow-up PR shortly to mock sys.stdout properly.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Nov 1, 2026

Copy link
Copy Markdown

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

Hi! The buildbot ARM64 Raspbian Debug 3.x (tier-3) has failed when building commit c29f95a.

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/1829/builds/3671) and take a look at the build logs.
  4. Check if the failure is related to this commit (c29f95a) 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/1829/builds/3671

Failed tests:

  • test_ftplib

Failed subtests:

  • test_cli_retrieve_file - test.test_ftplib.CommandLineTest.test_cli_retrieve_file

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/mnt/ssd/buildbot/buildarea/3.x.savannah-raspbian/build/Lib/unittest/mock.py", line 1437, in patched
    return func(*newargs, **newkeywargs)
  File "/mnt/ssd/buildbot/buildarea/3.x.savannah-raspbian/build/Lib/test/test_ftplib.py", line 1246, in test_cli_retrieve_file
    ftplib.test()
    ~~~~~~~~~~~^^
  File "/mnt/ssd/buildbot/buildarea/3.x.savannah-raspbian/build/Lib/ftplib.py", line 968, in test
    sys.stdout.buffer.write, 1024)
    ^^^^^^^^^^^^^^^^^
AttributeError: '_io.StringIO' object has no attribute 'buffer'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rudy-07 rudy-07 mentioned this pull request Nov 1, 2026
gh-131178: Fix test_cli_retrieve_file when stdout is StringIO in test_ftplib #161135
Merged
@rudy-07

rudy-07 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

I opened a follow-up PR to fix the sys.stdout.buffer AttributeError in est_cli_retrieve_file: #161135.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orsenthil orsenthil added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes and removed needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 2, 2026
@miss-islington-app

miss-islington-app Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks @rudy-07 for the PR, and @orsenthil for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks @rudy-07 for the PR, and @orsenthil for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Nov 2, 2026

Copy link
Copy Markdown

GH-161153 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 2, 2026
@bedevere-app

bedevere-app Bot commented Nov 2, 2026

Copy link
Copy Markdown

GH-161154 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 2, 2026
orsenthil added a commit that referenced this pull request Nov 2, 2026
@miss-islington @rudy-07 @orsenthil
[3.14] gh-131178: Add tests for ftplib command-line interface (GH-1…
86b2b3e
…61080) (#161153)

* gh-131178: Add tests for ftplib command-line interface

Add unit tests in Lib/test/test_ftplib.py covering the ftplib command-line interface: verifying usage message on empty invocation, subprocess invocation, host connection with debuglevel, directory and passive mode commands, file retrieval, and custom netrc file error handling.

(cherry picked from commit c29f95a)

Co-authored-by: Rudransh Shekhar <[email protected]>
Co-authored-by: Senthil Kumaran <[email protected]>
orsenthil added a commit that referenced this pull request Nov 2, 2026
@miss-islington @rudy-07 @orsenthil
[3.15] gh-131178: Add tests for ftplib command-line interface (GH-1…
0d43164
…61080) (#161154)

* gh-131178: Add tests for ftplib command-line interface

Add unit tests in Lib/test/test_ftplib.py covering the ftplib command-line interface: verifying usage message on empty invocation, subprocess invocation, host connection with debuglevel, directory and passive mode commands, file retrieval, and custom netrc file error handling.

(cherry picked from commit c29f95a)


Co-authored-by: Rudransh Shekhar <[email protected]>
Co-authored-by: Senthil Kumaran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@orsenthil orsenthil orsenthil approved these changes
@giampaolo giampaolo Awaiting requested review from giampaolo giampaolo is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@rudy-07 @orsenthil @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.