FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131178: Add tests for zipapp command-line interface by timurmamedov1 · Pull Request #150203 · python/cpython · GitHub

/ cpython Public

gh-131178: Add tests for zipapp command-line interface - #150203

Open
timurmamedov1 wants to merge 1 commit into
python:mainfrom
timurmamedov1:gh-131178-zipapp-cli-tests
Open

gh-131178: Add tests for zipapp command-line interface#150203
timurmamedov1 wants to merge 1 commit into
python:mainfrom
timurmamedov1:gh-131178-zipapp-cli-tests

Conversation

timurmamedov1 commented May 21, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown

Add CommandLineTest class with subprocess-based tests for python -m zipapp, covering:

  • --help
  • Archive creation (-o, -p, -m, -c)
  • --info (with/without interpreter, nonexistent file)
  • Archive copying
  • Error cases (in-place copy, changing main on copy, missing source, no __main__.py)

Copilot AI review requested due to automatic review settings May 21, 2026 22:19

python-cla-bot Bot commented May 21, 2026
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR extends CPython’s zipapp test suite by adding a new subprocess-driven test class that exercises the real python -m zipapp command-line interface, complementing the existing in-process zipapp.main() CLI tests.

Changes:

  • Add a CommandLineTest class that runs python -m zipapp in a subprocess and validates key CLI behaviors (--help, create/copy archives, --info, and common error cases).
  • Add a NEWS entry documenting the new subprocess-based CLI coverage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Lib/test/test_zipapp.py Adds subprocess-based CLI tests for python -m zipapp and related helpers.
Misc/NEWS.d/next/Tests/2026-05-21-22-06-07.gh-issue-131178.zipapp_cli.rst Notes the addition of subprocess-based zipapp CLI tests.
Comments suppressed due to low confidence (2)

Lib/test/test_zipapp.py:561

  • This test currently treats any non-zero exit as success. To avoid false positives, also assert that stderr includes the specific message for in-place archive edits ("In-place editing of archives is not supported").
    def test_copy_archive_inplace_fails(self):
        original = self._make_archive()
        result = self._run(str(original), '-o', str(original))
        self.assertNotEqual(result.returncode, 0)

Lib/test/test_zipapp.py:567

  • Similar to the other negative tests, this only asserts a non-zero return code. To prevent the test passing for an unrelated failure mode, also check stderr contains the expected message for attempting to change the main function when copying ("Cannot change the main function when copying").
    def test_copy_archive_change_main_fails(self):
        original = self._make_archive()
        target = self.tmpdir / 'copy.pyz'
        result = self._run(str(original), '-o', str(target), '-m', 'foo:bar')
        self.assertNotEqual(result.returncode, 0)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Lib/test/test_zipapp.py
Comment on lines +468 to +472
def _run(self, *args):
return subprocess.run(
[sys.executable, '-m', 'zipapp', *args],
capture_output=True,
)
Comment thread Lib/test/test_zipapp.py
Comment on lines +546 to +549
def test_info_nonexistent_file(self):
target = self.tmpdir / 'nonexistent.pyz'
result = self._run(str(target), '--info')
self.assertNotEqual(result.returncode, 0)
timurmamedov1 force-pushed the gh-131178-zipapp-cli-tests branch 3 times, most recently from 35dfe24 to 2a31466 Compare June 21, 2026 18:26
timurmamedov1 requested a review from Copilot June 21, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread Lib/test/test_zipapp.py
Comment on lines +459 to +461
@requires_subprocess()
class CommandLineTest(unittest.TestCase):
"""Test the ``python -m zipapp`` command-line interface via subprocess."""
timurmamedov1 force-pushed the gh-131178-zipapp-cli-tests branch from 9935ba9 to cf90fc6 Compare June 24, 2026 20:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL