-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implemented skip for Tools.Layouts in test_constant_exists with older OpticStudio versions #115
Implemented skip for Tools.Layouts in test_constant_exists with older OpticStudio versions #115
Conversation
…/v2.0.0/skip_viewer_tests_with_older_opticstudios # Conflicts: # tests/analyses/new/parsers/test_types.py
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.
Thanks for fixing this! I expect we will see more constants being added in future releases, so we may consider a more generic solution (e.g. with a dictionary mapping constants to the version in which they were added). Do you think we should opt for a more generic implementation now, or should we wait until more constants are added?
It might be nice to directly make it future proof. I see two options: MINIMAL_ZOS_VERSION_FOR_CONSTANT = { # Supply as {"constant": "zos version string"}
"Tools.Layouts": "24.1.0"
}
# ...
def test_constant_exists(self, zos, annotation, optic_studio_version): # noqa: ARG002
for constant_name, minimal_optic_studio_version in MINIMAL_ZOS_VERSION_FOR_CONSTANT.items():
if annotation.enum.startswith(constant_name) and optic_studio_version < minimal_optic_studio_version:
pytest.skip(f"{annotation.enum} is only available from OpticStudio {minimal_optic_studio_version} onwards") which is quite inefficient, but does the trick. Or MINIMAL_ZOS_VERSION_FOR_CONSTANTS = { # Supply as {"zos version string": constant}
"24.1.0": ["Tools.Layouts"]
}
# ...
def test_constant_exists(self, zos, annotation, optic_studio_version): # noqa: ARG002
for minimal_optic_studio_version, constant_names in MINIMAL_ZOS_VERSION_FOR_CONSTANTS.items():
if optic_studio_version < minimal_optic_studio_version and any(annotation.enum.startswith(constant_name) for constant_name in constant_names):
pytest.skip(f"{annotation.enum} is only available from OpticStudio {minimal_optic_studio_version} onwards") Which might be slightly more efficient as we first evaluate if we need to check it for this optic_studio_version and only if so we loop through the constants that should be skipped. Was this what you had in mind? |
I chose a slightly different implementation. @LucVV can you check if this works correctly in your OpticStudio version? |
Works great! |
Proposed change
test_constant_exists
currently tests all constants, including constants underTools.Layouts
. This fails on OpticStudio versions < 24R1 asTools.Layouts
did not exist yet. I think it is optimal to implement the skip within the tests in this instance, as the tested constants are outomatically determined.Type of change
Additional information
Related issues
Checklist
If you contributed an analysis:
AttrDict
s for the analysis result data (please use dataclasses instead).If you contributed an example: