Tuesday, 18 December 2018

Many pytest fixtures vs. one large "container" fixture

We have a large python project which is tested using pytest, currently with unittest style classes, and we started migrating it to module-based, function style tests.

We are having a debate whether we should:

  1. Split our large test base-class to many small, independent pytest fixtures; or
  2. Maintain a one large fixture which lazily imports all other fixtures.

Pros for many fixtures:

  • Modular and probably easy to maintain
  • Each test only uses what it needs

Pros for one large fixture:

  • Less boilerplate code, each test only has one extra keyword arg

What should we do? Any opinions are welcome as long as they are explained. Thanks :)



from Many pytest fixtures vs. one large "container" fixture

No comments:

Post a Comment