MOE
MOE copied to clipboard
[Python] improve pytest fixture use, e.g., scoping
pytest fixtures let us do a lot more than we could with the old teardown/setup style. We should stop emulating testify/xUnit and start using pytest: http://pytest.org/latest/fixture.html http://pytest.org/latest/builtin.html#fixtures-and-requests http://pythontesting.net/framework/pytest/pytest-fixtures-nuts-bolts/
The current implementation just translates testify's setup and class_setup functionality into pytest.fixture
. But fixtures are a lot more powerful. We can...
- use scope: only construct expensive things like
GaussianProcessTestCase
once - modularity and calling fixtures from other fixtures: simplify ``TestCase* hierarchies which were poor attempts to build fixtures inside of testify. combines with #409
- more granularity, able to specify fixtures per test and combine them easily
-
return
resources directly - and more!
edit: let's also think hard about "autouse". autouse makes it so that any test that can see the fixture will use the fixture. I feel like with stuff like this, you'd much rather opt-in explicitly than have fixtures running everywhere. see: http://pytest.org/latest/fixture.html#autouse-fixtures-xunit-setup-on-steroids