-
-
Notifications
You must be signed in to change notification settings - Fork 305
test(commands): centralize all --help tests in a file to dedup code #1726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(commands): centralize all --help tests in a file to dedup code #1726
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v4-11-0 #1726 +/- ##
========================================
Coverage 97.84% 97.84%
========================================
Files 60 60
Lines 2604 2604
========================================
Hits 2548 2548
Misses 56 56
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
097ef1f to
6c3ef01
Compare
6c3ef01 to
ecd05a4
Compare
ecd05a4 to
ce12748
Compare
| skip_below_py_3_13 = pytest.mark.skipif( | ||
| sys.version_info < (3, 13), | ||
| reason="The output message of argparse is different between Python 3.13 and lower than Python 3.13", | ||
| ) |
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.
The variable name itself does not reflect why we want to set this variable... this may make it hard for future contributors to understand the code correctly
| monkeypatch.setenv("COLUMNS", "80") | ||
| monkeypatch.setenv("TERM", "dumb") | ||
| monkeypatch.setenv("LC_ALL", "C") | ||
| monkeypatch.setenv("LANG", "C") | ||
| monkeypatch.setenv("NO_COLOR", "1") | ||
| monkeypatch.setenv("PAGER", "cat") |
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.
Copied from AI output. I know COLUMNS is necessary, but not sure for the rest
|
I don't understand what this is supposed to fix |
The behavior of When we try to add new options to the CLI, the help text changes, and usually we run |
|
The following pipeline result is a false alarm test failure caused by forgetting to skip the test below python 3.13. https://github.com/commitizen-tools/commitizen/actions/runs/20207591917/job/58008470452?pr=1724 Test passes for python version 3.13, 3.14 but not on 3.10 This PR can fix it. |
noirbizarre
left a comment
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.
Good to me, but I added some comment for possible later improvements
| @pytest.mark.skipif( | ||
| sys.version_info < (3, 13), | ||
| reason="The output message of argparse is different between Python 3.13 and lower than Python 3.13", | ||
| ) |
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.
Can't we have different snapshots for Python <3.13 and >=3.13 ?
It seems weird to have some tests skipped for some Python version for things that are existing on those Python versions
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.
Sounds good. I will check how to do it later and will do in another PR.
| # Force consistent terminal output | ||
| monkeypatch.setenv("COLUMNS", "80") | ||
| monkeypatch.setenv("TERM", "dumb") | ||
| monkeypatch.setenv("LC_ALL", "C") | ||
| monkeypatch.setenv("LANG", "C") | ||
| monkeypatch.setenv("NO_COLOR", "1") | ||
| monkeypatch.setenv("PAGER", "cat") |
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.
I think this could be a fixture like fixed_term for any test relying on output.
Basically, what it does:
COLUMNSfix the width of the termTERM=dumbdeactivate reactive output on libs supporting this (like spinners, progress bars...), better for static snapshots.LC_ALL=CandLANG=Cdisable localization and utf-8 chars in most CLI tools, it ensure test snapshot doesn't fail on non-english setupsNO_COLORis the now "standard" way of disabling ANSI color support (cf. https://no-color.org/)PAGER=catwill avoid user defined pagers likebatto change the output.
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.
will do in another PR
Test improvements
skip_below_py_3_13and missing forced consistent environment variables to reduce the chance of unnecessary file regression test failures.