0

I'm trying to process a bunch of files, which aren't known until the testing begins, and I want to add testing mechanisms to the processing so I know if there are any errors and get a report out at the end.

This processing requires a little bit of setup so a setup test needs runs once before the processing actually begins. Does anyone have any good examples of this kind of process being done in Python?

I've been researching this for the past few days and I haven't found any good solutions. A few options that I've seen are:

  • unittest: Using dynamically generated tests with a setUpClass method to do the setup.
  • Nose doesn't seem like an option at all because of the lack of continued support. This testing needs to last for a long time.
  • pytest (?): Not quite sure on this, the documentation isn't very good and I haven't found any concrete examples.

Basically I need a testing framework that has the ability to dynamically create parameterized tests with dependencies.

Ryan Schaefer
  • 3,047
  • 1
  • 26
  • 46
Cirrith
  • 147
  • 11
  • https://docs.pytest.org/en/latest/parametrize.html ? – G_M Mar 03 '18 at 23:35
  • Could I link it with this? https://stackoverflow.com/questions/12411431/pytest-how-to-skip-the-rest-of-tests-in-the-class-if-one-has-failed/12579625#12579625 – Cirrith Mar 03 '18 at 23:52
  • Do you mean mark it so it could be conditionally skipped? If so, I don't think that would be an issue. – G_M Mar 03 '18 at 23:53
  • So I just need a dependency mechanism then – Cirrith Mar 03 '18 at 23:54
  • I need to ensure the setup step succeeds before running the rest of the tests. So that means introducing a dependency or ensure a test order – Cirrith Mar 03 '18 at 23:58
  • Couldn't you just have a fixture where the setup is and then provide that fixture to those particular tests? Something like this (with the `yield`): https://docs.pytest.org/en/latest/fixture.html#fixture-finalization-executing-teardown-code – G_M Mar 04 '18 at 00:00
  • 1
    Yeah that looks like it would work. Thanks you! – Cirrith Mar 04 '18 at 00:30

0 Answers0