Page MenuHomeSoftware Heritage

Reset global state between unit test runs.
ClosedPublic

Authored by vlorentz on May 6 2019, 3:13 PM.

Details

Summary

Workaround for T1695 (This diff resets the state instead of completely
removing state)

Completely removing the global state would be much harder, and this
diff is enough to get meaningful errors when an Hypothesis-powered
test crashes.

It uses the _pre_setup hook used by hypothesis[django] to reset Django's database (which is a global state too)

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz created this revision.May 6 2019, 3:13 PM
vlorentz edited the summary of this revision. (Show Details)May 6 2019, 3:13 PM
vlorentz updated this revision to Diff 4698.May 6 2019, 3:15 PM

Remove useless reset.

vlorentz edited the summary of this revision. (Show Details)May 6 2019, 3:17 PM
anlambert accepted this revision.May 6 2019, 3:54 PM

Thanks for improving this! All tests still pass, so looks good to me.

swh/web/tests/strategies.py
427

Just a nitpick, maybe use a variable to store the tests data here instead of calling the get_tests_data function multiple times

This revision is now accepted and ready to land.May 6 2019, 3:54 PM
vlorentz updated this revision to Diff 4709.May 6 2019, 4:02 PM

Address @anlambert's comment.

This revision was landed with ongoing or failed builds.May 6 2019, 4:02 PM
This revision was automatically updated to reflect the committed changes.