TST: Fix issues with inconsistent tests #1018
Merged
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.
Context
This is an attempt to fix #1012.
For the first half of that issue (
test_line_edit.py
), this adds retries to the change in focus of the line edit while waiting for qtbot to confirm that the change actually took place. This appears to have made these stable for the tests I already changed in this way, and this doesn't affect what they are actually testing.For the stylesheet test failues in the issue, the only test that fails in isolation when a custom stylesheet is set is this one:
FAILED pydm/tests/utilities/test_stylesheet.py::test_stylesheet_get_style_data - assert 2 == 1
.The others are fine when run by themselves even with a stylesheet set.
But
test_stylesheet_get_style_data
makes changes to thePYDM_STYLESHEET
environment variable, as well as the locally stored stylesheet, and does not clean up after itself if it fails. Then those left over modifications cause the other tests later in the run to fail too.So the first fix is just to get that test to pass when a custom stylesheet is set. Then I also added a fixture to make sure it always cleans up after even if it fails, and set both tests in that file to use it since the other one has the same problem too.
Testing
Ran the tests with
PYDM_STYLESHEET
set to https://github.com/pcdshub/vacuumscreens/blob/master/styleSheet/masterStyleSheet.qss