Skip to content

Conversation

@pretty-parrot
Copy link

What is the purpose of this PR

  • This PR patches wopmars/tests/test_wopmars.py::TestWopmars::test_dry_run and prevents it from failing when it is run after wopmars/tests/test_tool_wrapper_thread.py::TestToolWrapperThread::test_run
  • Test is flaky (non-deterministic) and fails due to some state set up by wopmars/tests/test_tool_wrapper_thread.py::TestToolWrapperThread::test_run, but the test passes when it is run by itself otherwise

Expected Result

  • Test wopmars/tests/test_wopmars.py::TestWopmars::test_dry_run should pass when run both by itself and after wopmars/tests/test_tool_wrapper_thread.py::TestToolWrapperThread::test_run

Actual Result

  • Test wopmars/tests/test_wopmars.py::TestWopmars::test_dry_run fails when it is run after wopmars/tests/test_tool_wrapper_thread.py::TestToolWrapperThread::test_run
  • Specifically, we get the following:
____________________________________________________________________________________________ TestWopmars.test_dry_run _____________________________________________________________________________________________

self = <wopmars.tests.test_wopmars.TestWopmars testMethod=test_dry_run>

    def test_dry_run(self):
        cmd_line = ["python", "--dry-run", "-D", self.__db_url, "-w", self.__example_def_file1, "-v", "-d",
                    self.test_path]
        with self.assertRaises(SystemExit) as se:
            WopMars().run(cmd_line)
        # The tests is that these files do not exist
>       self.assertFalse(os.path.exists(os.path.join(self.test_path, 'outdir/output_file1.txt')))
E       AssertionError: True is not false

/home/ar-vi/wopmars/wopmars/tests/test_wopmars.py:207: AssertionError

Reproduce the test failure

  • Run python3 -m pytest wopmars/tests/test_tool_wrapper_thread.py::TestToolWrapperThread::test_run wopmars/tests/test_wopmars.py::TestWopmars::test_dry_run

Why the Test Fails

  • The test fails because of some "pollution"/state that is set by wopmars/tests/test_tool_wrapper_thread.py::TestToolWrapperThread::test_run .

Fix

  • The changes in this pull request clean up the state caused by the test run prior and makes the test pass.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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