ivankorobkov / python-inject

Python dependency injection
Apache License 2.0
671 stars 77 forks source link

Support for parallel test execution #74

Closed languitar closed 3 years ago

languitar commented 3 years ago

Is there any support or plan for enabling parallel test execution with inject?

ivankorobkov commented 3 years ago

Hi!

What do you mean by parallel test execution with inject? Can you give an example?

languitar commented 3 years ago

For instance for pyest, pytest-parallel provides a way to execute tests in multiple processes and also threads. For multi-threaded testing, the global nature of the inject instance is currently a hindrance, because reconfiguring the injector for one test might affect another test currently running in another parallel thread.

ivankorobkov commented 3 years ago

The inject API is built on top of a global injector singleton. Getting rid of this singleton requires rewriting the API and dramatically complicates usage and thread-safety.

However, you still can use pytest-parallel to run tests in parallel:

languitar commented 3 years ago

Ok, I know about xdist and that option. This was more a question of whether something like that is generally in scope or not.

Btw. do you have a preferred way of how to integrate inject with pytest fixtures?

ivankorobkov commented 3 years ago

Btw. do you have a preferred way of how to integrate inject with pytest fixtures?

Well, I've never used pytest.

languitar commented 3 years ago

Ok. Thanks for the help in any case!