-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add marker for case insensitive test collection by component and importance #15005
Add marker for case insensitive test collection by component and importance #15005
Conversation
trigger: test-robottelo |
pytest tests/foreman/ --component auditlog |
pytest_plugins/metadata_markers.py
Outdated
@@ -191,8 +191,8 @@ def pytest_collection_modifyitems(items, config): | |||
# Add marker starting at smallest docstring scope | |||
# only add the mark if it hasn't already been applied at a lower scope | |||
doc_component = component_regex.findall(docstring) | |||
if doc_component and 'component' not in item_mark_names: | |||
item.add_marker(pytest.mark.component(doc_component[0])) | |||
if doc_component and 'CaseComponent' not in item_mark_names: |
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.
why did you change the component
to CaseComponent
. we are adding component
as marker to the test not CaseComponent
. Or did I missed anything here ?
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.
It searches for CaseComponent docstring in the test.
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.
@jyejare I think it should be component
right ? CaseComponent
would not be a right marker to check as it it will not be there. As the we are adding the component marker.
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.
@shweta83 Here @omkarkhatavkar is right we are adding a keypair
of component=<somcomponent>
to the the test item.
In below compoenent not in item_mark_names
verifies that the component marker is not already added to the item.
if doc_component and 'component' not in item_mark_names:
@shweta83 Please revisit the tests are not collecting. Please let me know if u need the help. |
trigger: test-robottelo |
It was working well on my local setup. I need to check what's the issue running on CI. |
trigger: test-robottelo |
PRT Result
|
Tests are collected as expected. I messed up in running previous PRT which failed the test collection. |
pytest_plugins/metadata_markers.py
Outdated
@@ -164,7 +164,7 @@ def pytest_collection_modifyitems(items, config): | |||
# split the option string and handle no option, single option, multiple | |||
# config.getoption(default) doesn't work like you think it does, hence or '' | |||
importance = [i for i in (config.getoption('importance') or '').split(',') if i != ''] |
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.
Mind doing the same to importance, while at it?
importance = [i for i in (config.getoption('importance') or '').split(',') if i != ''] | |
importance = [i.lower() for i in (config.getoption('importance') or '').split(',') if i != ''] |
- update the commit message
8b56245
to
a7f2734
Compare
trigger: test-robottelo |
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.
ACK pending comments.
pytest_plugins/metadata_markers.py
Outdated
@@ -191,8 +191,8 @@ def pytest_collection_modifyitems(items, config): | |||
# Add marker starting at smallest docstring scope | |||
# only add the mark if it hasn't already been applied at a lower scope | |||
doc_component = component_regex.findall(docstring) | |||
if doc_component and 'component' not in item_mark_names: | |||
item.add_marker(pytest.mark.component(doc_component[0])) | |||
if doc_component and 'CaseComponent' not in item_mark_names: |
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.
@shweta83 Here @omkarkhatavkar is right we are adding a keypair
of component=<somcomponent>
to the the test item.
In below compoenent not in item_mark_names
verifies that the component marker is not already added to the item.
if doc_component and 'component' not in item_mark_names:
pytest_plugins/metadata_markers.py
Outdated
if doc_component and 'component' not in item_mark_names: | ||
item.add_marker(pytest.mark.component(doc_component[0])) | ||
if doc_component and 'CaseComponent' not in item_mark_names: | ||
item.add_marker(pytest.mark.component(doc_component[0].lower())) | ||
doc_importance = importance_regex.findall(docstring) | ||
if doc_importance and 'importance' not in item_mark_names: | ||
item.add_marker(pytest.mark.importance(doc_importance[0])) |
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.
item.add_marker(pytest.mark.importance(doc_importance[0])) | |
item.add_marker(pytest.mark.importance(doc_importance[0].lower())) |
PRT Result
|
a7f2734
to
87ba96b
Compare
trigger: test-robottelo |
PRT Result
|
… and importance (#15233) Add marker for case insensitive test collection by component and importance (#15005) Collect tests with case insensitive component marker (cherry picked from commit 3fa1539) Co-authored-by: Shweta Singh <[email protected]>
… and importance (#15231) Add marker for case insensitive test collection by component and importance (#15005) Collect tests with case insensitive component marker (cherry picked from commit 3fa1539) Co-authored-by: Shweta Singh <[email protected]>
… and importance (#15232) Add marker for case insensitive test collection by component and importance (#15005) Collect tests with case insensitive component marker (cherry picked from commit 3fa1539) Co-authored-by: Shweta Singh <[email protected]>
…rtance (SatelliteQE#15005) Collect tests with case insensitive component marker
Problem Statement
We need case insensitive test collection component-wise
Solution
Added marker for component-wise test collection
result:
pytest tests/foreman/ --component auditlog
collected 5434 items / 5426 deselected / 8 selected
=======================================================
Related Issues