You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: make colour tests independent of an ambient NO_COLOR (#34) - #48
NO_COLOR=1 env -u TERM python -m pytest -q (serial)
n/a
2004 passed
env -u NO_COLOR -u TERM python -m pytest -q -n 8
2004 passed
2004 passed
No test was skipped, removed or loosened. The NO_COLOR behaviour tests still set NO_COLOR themselves.
Summary by Sourcery
Ensure colour tests produce consistent results regardless of the environment in which the test suite runs.
Enhancements:
Make the test suite's colour checks independent of an ambient NO_COLOR environment variable.
Tests:
Add shared test-session setup that clears ambient NO_COLOR while preserving explicit coverage of NO_COLOR behaviour.
Summary by CodeRabbit
Tests
Test runs now begin without an inherited NO_COLOR setting affecting color-related checks.
Checks that cover NO_COLOR behavior set it explicitly, making results more consistent across environments and ensuring those scenarios remain tested. This improves the reliability of automated checks without changing the application’s behavior for end users.
Clear an ambient NO_COLOR during test-session setup so colour tests are independent of the caller’s environment.
rege/tests/conftest.py L1-13
Tips and commands
Interacting with Sourcery
Trigger a new review: Comment @sourcery-ai review on the pull request.
Continue discussions: Reply directly to Sourcery's review comments.
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with @sourcery-ai issue to create an issue from it.
Generate a pull request title: Write @sourcery-ai anywhere in the pull
request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
Generate a pull request summary: Write @sourcery-ai summary anywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment @sourcery-ai summary on the pull request to
(re-)generate the summary at any time.
Generate reviewer's guide: Comment @sourcery-ai guide on the pull
request to (re-)generate the reviewer's guide at any time.
Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!
This change only adjusts test setup so an ambient NO_COLOR variable no longer causes spurious color-test failures. It has no production impact and is low risk to merge.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
Issue #34 is the only active direct target. Its coding requirement for Colors isolation is implemented. The head diff adds rege/tests/conftest.py, which runs os.environ.pop("NO_COLOR", None) before te…
Provide evidence for the following: (1) Results of the two Colors tests run alone and after tests that disable colors, in canonical and permuted order, at head cca817c. (2) A bounded-timeout run of test_repl…
Passed checks: 3 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: test colour checks are made independent of an ambient NO_COLOR environment variable. The change adds rege/tests/conftest.py, which removes NO_COLOR before rege.formatt…
Out of Scope Changes check
The whole-PR diff against merge base 7ac2f37 changes one file: rege/tests/conftest.py (+13 lines, new file). The change clears NO_COLOR before rege.formatting import, …
Full details: Title check
Explanation
The title names the main change: test colour checks are made independent of an ambient NO_COLOR environment variable. The change adds rege/tests/conftest.py, which removes NO_COLOR before rege.formatting is imported. The title uses the British spelling 'colour' while the code and tests use 'color'. The title also carries an issue reference (#34), which is acceptable.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against merge base 7ac2f37 changes one file: rege/tests/conftest.py (+13 lines, new file). The change clears NO_COLOR before rege.formatting import, which directly serves the Colors-isolation objective of #34. The file has no library code changes. The docstring states that tests exercising NO_COLOR set the variable themselves, and the PR receipt reports no test was skipped, removed, or loosened. No unrelated change is shown in the diff.
Full details: Linked Issues check
Explanation
Issue #34 is the only active direct target. Its coding requirement for Colors isolation is implemented. The head diff adds rege/tests/conftest.py, which runs os.environ.pop("NO_COLOR", None) before test modules import rege.formatting. This matches the issue step 3 request to make module-state isolation deterministic when the defect persists. The PR receipt reports 2004 passed for NO_COLOR=1 with -n 8 and serial runs, against 2 failures on main. Evidence gaps remain. (a) Issue steps 3 and the permutation concern require the two Colors tests to be reproduced individually and after color-disabling tests. The receipt does not show this. The issue states that the failure may come from shared state left by an earlier disabling test. The conftest only clears the environment variable, so it does not address shared Colors attributes set by other tests. (b) Issue step 2 requires the REPL EOF/interrupt test (test_repl_ctrl_c_interrupt) to run with an external bounded timeout. The PR does not report this, and the PR objectives state it is not completed. (c) Issue steps 1 and 4 require a run with the pinned declared dependency versions and recorded JUnit output. The receipt uses click 8.5.1 and pytest 9.2.0 and does not record JUnit, skips, or errors. Steps 2 and 4 are execution and evidence tasks. Their outcome decides whether any further code change is needed, so the coding status cannot be confirmed.
Resolution
Provide evidence for the following: (1) Results of the two Colors tests run alone and after tests that disable colors, in canonical and permuted order, at head cca817c. (2) A bounded-timeout run of test_repl_ctrl_c_interrupt that shows the CLI exits or raises the intended condition. (3) A full-suite run with the declared dependency versions from the snapshot, with JUnit output and resolved package versions recorded. If (1) shows the Colors tests still fail in permuted order, the PR must add deterministic isolation for Colors state. If (2) shows a loop or hang, the REPL EOF/interrupt path requires a code fix in scope for #34.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 11e25d50-e0a5-406d-b2ac-91d10eb83649
Commits
Reviewing files that changed from the base of the PR and between 7ac2f37 and cca817c.
Files selected for processing: 1
rege/tests/conftest.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
#34 Reproduce census test boundaries under declared dependencies: REPL EOF and Colors isolation · 0 of 5 met · 1 to check by hand
#
Requirement
Status
Notes
1
Reproduce the pinned snapshot in an unprivileged environment with its declared dependencies and record resolved versions.
🟡 Partly met
The receipt records Python, pytest and click versions for the PR-base and head runs, but does not establish that it reproduced the issue's pinned snapshot or ran unprivileged.
2
Run the REPL EOF/interrupt test with a bounded timeout and verify its exit behavior.
❌ Not addressed
The receipt contains no bounded REPL EOF/interrupt test result.
3
Reproduce the Colors tests individually and after tests that disable colors; make isolation deterministic only if the defect persists.
🟡 Partly met
The receipt reproduces failures under ambient NO_COLOR and reports that clearing it resolves them, but does not report individual or test-order reproductions.
4
Run the complete suite, save JUnit, skips, errors and the exact source head, and distinguish environment-only resolution from a repository fix.
🟡 Partly met
The receipt reports complete-suite results, the verified head and the environment-only change, but does not report saved JUnit results or skips and errors.
5
Return the execution result to the LAVREA evidence record.
👀 Check by hand (external system)
Check whether the receipt and execution result were added to the LAVREA evidence record.
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments### Comment 1
<locationpath="rege/tests/conftest.py"line_range="13" />
<code_context>
+
+import os
+
+os.environ.pop("NO_COLOR", None)
</code_context>
<issue_to_address>
**Caller loses its colour setting**
When pytest is invoked with `pytest.main()` in a long-lived process whose environment has `NO_COLOR` set, `os.environ.pop` removes the caller’s `NO_COLOR` in the pytest host process, and this conftest has no teardown to restore it, so subsequent application output in that process includes ANSI colours.
Save the original value and restore it in a pytest session teardown hook.
</issue_to_address>
### Comment 2
<locationpath="rege/tests/conftest.py"line_range="13" />
<code_context>
+
+import os
+
+os.environ.pop("NO_COLOR", None)
</code_context>
<issue_to_address>
**Change lacks narrative counterpart**
When this PR adds test-suite setup without a `docs/logos/` update, the added test-session environment change has no corresponding entry in `docs/logos/`, so the required narrative record omits this change.
Add a corresponding update to the narrative record in `docs/logos/`.
</issue_to_address>
### Comment 3
<locationpath="rege/tests/conftest.py"line_range="13" />
<code_context>
+
+import os
+
+os.environ.pop("NO_COLOR", None)
</code_context>
<issue_to_address>
**Verify module-state isolation**
The issue asks to reproduce the Colors tests individually and after tests that disable colors before attributing the failures. This setup clears ambient NO_COLOR, but the receipt does not establish whether order-dependent module-state failures persist.
</issue_to_address>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Caller loses its colour setting
When pytest is invoked with pytest.main() in a long-lived process whose environment has NO_COLOR set, os.environ.pop removes the caller’s NO_COLOR in the pytest host process, and this conftest has no teardown to restore it, so subsequent application output in that process includes ANSI colours.
Save the original value and restore it in a pytest session teardown hook.
Prompt for AI agents
In `rege/tests/conftest.py` at line 13:
**Caller loses its colour setting**
When pytest is invoked with `pytest.main()` in a long-lived process whose environment has `NO_COLOR` set, `os.environ.pop` removes the caller’s `NO_COLOR` in the pytest host process, and this conftest has no teardown to restore it, so subsequent application output in that process includes ANSI colours.
Save the original value and restore it in a pytest session teardown hook.
The reason will be displayed to describe this comment to others. Learn more.
⚪ Low · Change lacks narrative counterpart
When this PR adds test-suite setup without a docs/logos/ update, the added test-session environment change has no corresponding entry in docs/logos/, so the required narrative record omits this change.
Add a corresponding update to the narrative record in docs/logos/.
Prompt for AI agents
In `rege/tests/conftest.py` at line 13:
**Change lacks narrative counterpart**
When this PR adds test-suite setup without a `docs/logos/` update, the added test-session environment change has no corresponding entry in `docs/logos/`, so the required narrative record omits this change.
Add a corresponding update to the narrative record in `docs/logos/`.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Verify module-state isolation
The issue asks to reproduce the Colors tests individually and after tests that disable colors before attributing the failures. This setup clears ambient NO_COLOR, but the receipt does not establish whether order-dependent module-state failures persist.
Prompt for AI agents
In `rege/tests/conftest.py` at line 13:
**Verify module-state isolation**
The issue asks to reproduce the Colors tests individually and after tests that disable colors before attributing the failures. This setup clears ambient NO_COLOR, but the receipt does not establish whether order-dependent module-state failures persist.
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
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.
Closes #34
Adds
rege/tests/conftest.py, which removes an ambientNO_COLORbefore the suite importsrege.formatting. Tests only. No library code changes.Verification receipt
Head verified:
cca817cc5e7818c22d9b6ef972f1b1a83223c300. Python 3.13 venv withpip install -e '.[dev]' pytest-xdist(click 8.5.1, pytest 9.2.0).7ac2f37)NO_COLOR=1 env -u TERM python -m pytest -q -n 8test_colors_defined,test_no_color_env_triggers_disable)NO_COLOR=1 env -u TERM python -m pytest -q(serial)env -u NO_COLOR -u TERM python -m pytest -q -n 8No test was skipped, removed or loosened. The NO_COLOR behaviour tests still set
NO_COLORthemselves.Summary by Sourcery
Ensure colour tests produce consistent results regardless of the environment in which the test suite runs.
Enhancements:
NO_COLORenvironment variable.Tests:
NO_COLORwhile preserving explicit coverage of NO_COLOR behaviour.Summary by CodeRabbit
NO_COLORsetting affecting color-related checks.NO_COLORbehavior set it explicitly, making results more consistent across environments and ensuring those scenarios remain tested. This improves the reliability of automated checks without changing the application’s behavior for end users.