goodmami / penman

PENMAN notation (e.g. AMR) in Python
https://penman.readthedocs.io/
MIT License
139 stars 27 forks source link

Fix flaky tests/test_layout.py::test_rearrange #102

Closed shenganzhang closed 2 years ago

shenganzhang commented 2 years ago

This PR aims to fix the flaky test tests/test_layout.py::test_rearrange. In previous versions, the test will run into randomly in rearrange(t, model.random_order) case. And the reason is that the globally defined random.seed(1) seems not working well here, so I define the seed inside that test case. The test failure can be reproduced by running pytest possibly for multiple times. Notice that the PR is modifying the test to make it more robust without changing the source code.

goodmami commented 2 years ago

Thanks for this! I was unable to reproduce with multiple Python versions and running the tests multiple times in quick succession. But I don't doubt that there may be an issue here as pytest does some non-obvious things when setting up tests, so setting the random seed within the test itself seems safer than doing it within the module.