fix: add explicit test IDs to environment parametrizations
Metadata
Current evaluation
Adds explicit test IDs to parametrized tests in almalinux, centos_7, and ubuntu_buildd test files to fix pytest collection errors caused by newline characters in auto-generated test IDs.
Suggested action: needs review
Reason: The PR fixes a real pytest collection error (issue #858) by adding explicit test IDs to parametrized tests, preventing newline characters from breaking test setup. The change is minimal (+6/-0 lines) and correct, but has been inactive for 273 days without maintainer review or merge.
Impact:
50
Quick Win:
42.5
Staleness:
75
Complexity:
15
Confidence:
70
Issue body
- [ ] Have you followed the guidelines for contributing?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `make lint && make test`?
---
## Description
Pytest was failing during test collection when parametrize decorators lacked explicit IDs for parameters containing byte strings with newlines. The auto-generated test IDs embedded literal `\n` characters, breaking test setup:
```
ERROR at setup of test_setup[...-https_proxy=http://foo.bar:8081\nPATH=/snap\nhttp_proxy=http://foo.bar:8080\n-AlmaLinuxBaseAlias.NINE]
```
## Changes
Added `ids=["default-env", "custom-env"]` to environment parametrizations in:
- `tests/unit/bases/test_almalinux.py` (2 occurrences)
- `tests/unit/bases/test_centos_7.py` (2 occurrences)
- `tests/unit/bases/test_ubuntu_buildd.py` (2 occurrences)
No functional changes. Test IDs now render as `test_setup[...-default-env-...]` instead of embedding raw byte string values.
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by firewall rules:
>
> - `astral.sh`
> - Triggering command: `/usr/bin/curl curl -LsSf REDACTED` (dns block)
>
> If you need me to access, download, or install something from one of these locations, you can either:
>
> - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/canonical/craft-providers/settings/copilot/coding_agent) (admins only)
>
> </details>
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
----
*This section details on the original issue you should resolve*
<issue_title>Error when setting up almalinux test</issue_title>
<issue_description>### Bug Description
We got an error when setting up an almalinux test: https://github.com/canonical/craft-providers/actions/runs/19582107478/job/56082351892?pr=852
### To Reproduce
https://github.com/canonical/craft-providers/actions/runs/19582107478/job/56082351892?pr=852
### part yaml
```shell
```
### Relevant log output
```shell
025-11-21T20:26:27.1887245Z _ ERROR at setup of test_setup[None-almalinux-base-v7-packages1-expected_packages1-None-expected_snap_call0-False-environment1-https_proxy=http://foo.bar:8081\nPATH=/snap\nhttp_proxy=http://foo.bar:8080\n-AlmaLinuxBaseAlias.NINE] _
2025-11-21T20:26:27.1888392Z
2025-11-21T20:26:27.1888588Z thread = <InstanceTimer(Thread-9, stopped daemon 139927579784768)>
2025-11-21T20:26:27.1889633Z
2025-11-21T20:26:27.1889752Z def invoke_excepthook(thread):
2025-11-21T20:26:27.1890049Z global excepthook
2025-11-21T20:26:27.1890279Z try:
2025-11-21T20:26:27.1890481Z hook = excepthook
2025-11-21T20:26:27.1890734Z if hook is None:
2025-11-21T20:26:27.1890986Z hook = old_excepthook
2025-11-21T20:26:27.1891247Z
2025-11-21T20:26:27.1891479Z args = ExceptHookArgs([*sys_exc_info(), thread])
2025-11-21T20:26:27.1891789Z
2025-11-21T20:26:27.1891965Z > hook(args)
2025-11-21T20:26:27.1892109Z
2025-11-21T20:26:27.1892227Z /usr/lib/python3.10/threading.py:1326:
2025-11-21T20:26:27.1892564Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-11-21T20:26:27.1893346Z /home/runner/work/craft-providers/craft-providers/.venv/lib/python3.10/site-packages/_pytest/threadexception.py:111: in thread_exception_hook
2025-11-21T20:26:27.1894141Z tracemalloc_tb = "\n" + tracemalloc_message(args.thread)
2025-11-21T20:26:27.1894540Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-11-21T20:26:27.1894776Z
2025-11-21T20:26:27.1894967Z source = <InstanceTimer(Thread-9, stopped daemon 139927579784768)>
2025-11-21T20:26:27.1895257Z
2025-11-21T20:26:27.1895400Z def tracemalloc_message(source: object) -> str:
2025-11-21T20:26:27.1895687Z if source is None:
2025-11-21T20:26:27.1895898Z return ""
2025-11-21T20:26:27.1896075Z
2025-11-21T20:26:27.1896229Z try:
2025-11-21T20:26:27.1896739Z > import tracemalloc
2025-11-21T20:26:27.1896983Z E KeyError: 'tracemalloc'
2025-11-21T20:26:27.1897151Z
2025-11-21T20:26:27.1897531Z /home/runner/work/craft-providers/craft-providers/.venv/lib/python3.10/site-packages/_pytest/tracemalloc.py:9: KeyError
2025-11-21T20:26:27.1897992Z
2025-11-21T20:26:27.1898163Z The above exception was the direct cause of the following exception:
2025-11-21T20:26:27.1898429Z
2025-11-21T20:26:27.1898534Z cls = <class '_pytest.runner.CallInfo'>
2025-11-21T20:26:27.1899103Z func = <function call_and_report.<locals>.<lambda> at 0x7f436dce3be0>
2025-11-21T20:26:27.1899580Z when = 'setup'
2025-11-21T20:26:27.1899880Z reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
2025-11-21T20:26:27.1900146Z
2025-11-21T20:26:27.1900226Z @classmethod
2025-11-21T20:26:27.1900406Z def from_call(
2025-11-21T20:26:27.1900584Z cls,
2025-11-21T20:26:27.1900768Z func: Callable[[], TResult],
2025-11-21T20:26:27.1901071Z when: Literal["collect", "setup", "call", "teardown"],
2025-11-21T20:26:27.1901485Z reraise: type[BaseException] | tuple[type[BaseException], ...] | None = None,
2025-11-21T20:26:27.1901861Z ) -> CallInfo[TResult]:
2025-11-21T20:26:27.1902118Z """Call func, wrapping the result in a CallInfo.
2025-11-21T20:26:27.1902379Z
2025-11-21T20:26:27.1902546Z :param func:
2025-11-21T20:26:27.1902785Z The function to call. Called without arguments.
2025-11-21T20:26:27.1903115Z :type func: Callable[[], _pytest.runner.TResult]
2025-11-21T20:26:27.1903392Z :param when:
2025-11-21T20:26:27.1903618Z The phase in which the function is called.
2025-11-21T20:26:27.1903879Z :param reraise:
2025-11-21T20:26:27.1904169Z Exception or exceptions that shall propagate if raised by the
2025-11-21T20:26:27.1904556Z function, instead of being wrapped in the CallInfo.
2025-11-21T20:26:27.1904828Z """
2025-11-21T20:26:27.1905004Z excinfo = None
2025-11-21T20:26:27.1905212Z instant = timing.Instant()
2025-11-21T20:26:27.1905428Z try:
2025-11-21T20:26:27.1905615Z > result: TResult | None = func()
2025-11-21T20:26:27.1905783Z
2025-11-21T20:26:27.1906123Z /home/runner/work/craft-providers/craft-providers/.venv/lib/python3.10/site-packages/_pytest/runner.py:344:
2025-11-21T20:26:27.1906646Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ...
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes canonical/craft-providers#858
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 |
Impact:
50
Quick Win:
42.5
Staleness:
75
Complexity:
15
Confidence:
70
|
needs review | Adds explicit test IDs to parametrized tests in almalinux, centos_7, and ubuntu_buildd test files to fix pytest collection errors caused by newline characters in auto-generated test IDs. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
88
Complexity:
10
Confidence:
85
|
close stale | Adds explicit pytest test IDs to environment parametrizations to prevent collection errors from newline characters in auto-generated IDs. PR has been inactive for 228 days with unresolved CI policy checks and no maintainer follow-up. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
85
Complexity:
10
Confidence:
80
|
close stale | Adds explicit IDs to pytest parametrizations to fix collection errors caused by newlines in auto-generated test names. PR has been inactive for 219 days with no maintainer review or merge. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
75
Complexity:
5
Confidence:
85
|
needs review | Adds explicit IDs to pytest parametrizations to prevent collection errors from newline characters in test names. Currently awaiting maintainer review after 202 days of inactivity. |
Update history
No update history recorded yet.
Related work
-
Related To:
canonical/craft-providers#858
(confidence 90%)
This PR directly addresses the pytest collection error described in issue #858, which remains open with no maintainer response.
Related issues
No related issues found above the similarity threshold.