Closed zhubonan closed 5 years ago
Example here:
The test profile will be used if AIIDA_TEST_PROFILE
environmental variable is set, otherwise fallback to creating new profiles/db cluster from scratch
Not sure how to detect the backend after profile loaded. Only works for django now.
Speed up: 26 s vs 4 s for 8 tests @ltalirz @chrisjsewell
@zhubonan Thanks, I'll be looking into this. I'm a little surprised that your numbers with the fixtures are so high - I'm not so familiar with pytest so I will need to check they are set up properly for pytest - with unittest, using a special runner, the postgres cluster should be set up only once for all tests and destroyed afterwards. 20s for this seems way too long.
@ltalirz It is only the setup time that is a bit long, so it slows down the processing of fixing bugs (e.g the run test/fix/re-run cycles). Running 8 tests and 40 tests should take rought the same time.
Once the initail setup is complete, the tests actually run fairly fast.
ok, thanks. so, good to know that at least the fixtures are doing what they are supposed to.
I agree that there can always be a use case where you want to run just a few tests and you may want to avoid the overhead of creating the postgres cluster (which is never going to be zero). I'll give your implementation a try!
It is now convenient to run just
pytest
in the test folder using the fixture defined inaiida.manage.fixtures.fixture_manager
. This creates a complete separate aiida profile and database. However, this process is relatively slow (~20 seconds) compared to the oldverdi -p <test_profile> devel tests
(no delay) method. This is becuase the postgres cluster needs to be created every time be migrated afterwards.It would be better to allow this
fixture_manager
to reuse the existing test_profile to speed things up. During plugin development sometimes there can be just a small change made and it is desirable to get the test results faster.