-
Notifications
You must be signed in to change notification settings - Fork 81
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
[RHELC-1293] Introduce pre-commit hook to register custom markers #1018
base: main
Are you sure you want to change the base?
Conversation
* Registering the custom markers is oftentimes tedious and can lead to oversight when registering a new marker or removing a deprecated one * this should ensure, that the configuration stays up-to-date with changes in existing markers Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1018 +/- ##
=======================================
Coverage 94.25% 94.25%
=======================================
Files 47 47
Lines 4526 4526
Branches 808 808
=======================================
Hits 4266 4266
Misses 183 183
Partials 77 77
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
return custom_markers | ||
|
||
|
||
def update_pytest_ini(custom_markers, ini_file="pytest.ini"): |
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.
Since it's a ini file, maybe you could use the configparser module to deal with it? https://docs.python.org/3/library/configparser.html
""" | ||
markers = set() | ||
# Regex to match the pytest markers | ||
marker_pattern = re.compile(r"@pytest\.mark\.(?P<marker>\w+)\(?") |
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.
^@pytest\.mark\.(\w)+
should be good enough
|
||
ini_startswith = '[pytest]\ntestpaths = "convert2rhel/unit_tests"\nmarkers =\n' | ||
with open(ini_file, "w", encoding="utf-8") as f: | ||
if custom_markers: |
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 would move the condition to the beginning of the function:
ini_startswith = '[pytest]\ntestpaths = "convert2rhel/unit_tests"\nmarkers =\n' | |
with open(ini_file, "w", encoding="utf-8") as f: | |
if custom_markers: | |
if custom_markers: | |
# Nothing to do | |
return | |
ini_startswith = '[pytest]\ntestpaths = "convert2rhel/unit_tests"\nmarkers =\n' | |
with open(ini_file, "w", encoding="utf-8") as f: |
Can we use this instead? Means we can get rid of a lot of the integration test specific markers (and just update the naming scheme of it) |
Jira Issues: RHELC-1293
Checklist
[RHELC-]
is part of the PR titleRelease Pending
if relevant