Skip to content

Fix a flaky test by cleaning a polluted state#15

Open
sturmianseq wants to merge 1 commit intomortele:masterfrom
sturmianseq:sturmianseq-fix-a-flaky-test
Open

Fix a flaky test by cleaning a polluted state#15
sturmianseq wants to merge 1 commit intomortele:masterfrom
sturmianseq:sturmianseq-fix-a-flaky-test

Conversation

@sturmianseq
Copy link

What is the purpose of the change

This PR is to fix a flaky test test/test_occam_data.py::test_occam_data_not_save_to_npy, which can fail after running test/test_occam_data.py::test_occam_data_attributes, but passes when it is run in isolation.

Reproduce the test failure

Run the following command:

python -m pytest test/test_occam_data.py::test_occam_data_attributes test/test_occam_data.py::test_occam_data_not_save_to_npy

Expected result

test/test_occam_data.py::test_occam_data_not_save_to_npy should pass after running test/test_occam_data.py::test_occam_data_attributes.

Actual result

    def test_occam_data_not_save_to_npy():
>       assert not os.path.exists(class_dir)
E       AssertionError: assert not True
E        +  where True = <function exists at 0x7f3b6d24cca0>('/home/yyy/pythonOD/explore_test/cprojects/OccamTools/test/../data/class_data')
E        +    where <function exists at 0x7f3b6d24cca0> = <module 'posixpath' from '/usr/lib/python3.8/posixpath.py'>.exists
E        +      where <module 'posixpath' from '/usr/lib/python3.8/posixpath.py'> = os.path

test/test_occam_data.py:217: AssertionError

Why it fails

The test class directory is not deleted after running test/test_occam_data.py::test_occam_data_attributes, which leads to a pollution.

Fix

Delete class_dir at the end of test/test_occam_data.py::test_occam_data_attributes

@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #15 (fb07682) into master (fcaaac4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         2328      2329    +1     
=========================================
+ Hits          2328      2329    +1     
Impacted Files Coverage Δ
test/test_occam_data.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcaaac4...fb07682. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant