Skip to content

Conversation

@JP-Ellis
Copy link
Contributor

📝 Summary

When trying to run tests with hatch run test path/to/test.py::test_fo, hatch keeps the first tests/ argument, which ends up including all of the tests anyway.

🚨 Breaking Changes

🔥 Motivation

🔨 Test Plan

🔗 Related issues/PRs

When trying to run tests with `hatch run test path/to/test.py::test_fo`,
hatch keeps the first `tests/` argument, which ends up including all of
the tests anyway.

Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis self-assigned this Nov 18, 2025
Copilot AI review requested due to automatic review settings November 18, 2025 09:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the test command configuration to properly handle user-specified test paths. The change allows users to run specific tests with hatch run test path/to/test.py::test_name without inadvertently running all tests due to the hardcoded tests/ argument being retained.

Key Changes:

  • Modified the pytest command to use {args:tests/} instead of hardcoded tests/ {args}, making tests/ a default value that gets replaced when arguments are provided

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

@JP-Ellis JP-Ellis enabled auto-merge (rebase) November 18, 2025 09:44
@codecov
Copy link

codecov bot commented Nov 18, 2025

❌ 8 Tests Failed:

Tests completed Failed Passed Skipped
13 8 5 0
View the top 3 failed test(s) by shortest run time
::examples.http.requests_and_fastapi.test_provider
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../http/requests_and_fastapi/test_provider.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../http/requests_and_fastapi/test_provider.py#x1B[0m:27: in <module>
    #x1B[0m#x1B[94mimport#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96muvicorn#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'uvicorn'#x1B[0m#x1B[0m
::examples.plugins.protobuf.test_consumer
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../plugins/protobuf/test_consumer.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../plugins/protobuf/__init__.py#x1B[0m:39: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mexamples#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mplugins#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mproto#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mperson_pb2#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m AddressBook, Person#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../plugins/proto/person_pb2.py#x1B[0m:17: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mgoogle#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mprotobuf#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m descriptor #x1B[94mas#x1B[39;49;00m _descriptor#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'google'#x1B[0m#x1B[0m
::examples.plugins.protobuf.test_provider
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../plugins/protobuf/test_provider.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../plugins/protobuf/__init__.py#x1B[0m:39: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mexamples#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mplugins#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mproto#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mperson_pb2#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m AddressBook, Person#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../plugins/proto/person_pb2.py#x1B[0m:17: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mgoogle#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mprotobuf#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m descriptor #x1B[94mas#x1B[39;49;00m _descriptor#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'google'#x1B[0m#x1B[0m
::examples.v2.tests.test_02_message_consumer
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../v2/tests/test_02_message_consumer.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../v2/tests/test_02_message_consumer.py#x1B[0m:40: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mpact#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mv2#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m MessageConsumer, MessagePact, Provider#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../pact/v2/__init__.py#x1B[0m:5: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mpact#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mv2#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mconsumer#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m Consumer#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../pact/v2/consumer.py#x1B[0m:2: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mpact#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m Pact#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../pact/v2/pact.py#x1B[0m:8: in <module>
    #x1B[0m#x1B[94mimport#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mpsutil#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'psutil'#x1B[0m#x1B[0m
::examples.v2.tests.test_03_message_provider
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../v2/tests/test_03_message_provider.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../v2/tests/test_03_message_provider.py#x1B[0m:32: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mpact#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mv2#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m MessageProvider#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../pact/v2/__init__.py#x1B[0m:5: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mpact#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mv2#x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mconsumer#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m Consumer#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../pact/v2/consumer.py#x1B[0m:2: in <module>
    #x1B[0m#x1B[94mfrom#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96m.#x1B[39;49;00m#x1B[04m#x1B[96mpact#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[94mimport#x1B[39;49;00m Pact#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[.../pact/v2/pact.py#x1B[0m:8: in <module>
    #x1B[0m#x1B[94mimport#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[04m#x1B[96mpsutil#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'psutil'#x1B[0m#x1B[0m
::pact-python-cli.tests.test_init
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../pact-python-cli/tests/test_init.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'tests.test_init'#x1B[0m#x1B[0m
::pact-python-cli.tests.test_telemetry
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../pact-python-cli/tests/test_telemetry.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'tests.test_telemetry'#x1B[0m#x1B[0m
::pact-python-ffi.tests.test_init
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../pact-python-ffi/tests/test_init.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../...../_temp/uv-python-dir/cpython-3.13.9-macos-aarch64-none/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m _bootstrap._gcd_import(name[level:], package, level)#x1B[90m#x1B[39;49;00m
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   ModuleNotFoundError: No module named 'tests.test_init'#x1B[0m#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants