I have several unit-tests (only python3.6 and higher) which are importing a helper class to setup some things (eg. pulling some Docker images) on the system before starting the tests.
The class is doing everything while it get instantiate. It needs to stay alive because it holds some information which are evaluated during the runtime and needed for the different tests.
The call of the helper class is very expensive and I wanna speedup my tests the helper class only once. My approach here would be to use a singleton but I was told that in most cases a singleton is not needed. Are there other options for me or is a singleton here actually a good solution?
The option should allow executing all tests at all and every test on his own.
Also I would have some theoretical questions.
If I use a singleton here how is python executing this in parallel? Is python waiting for the first instance to be finish or can there be a race condition? And if yes how do I avoid them?
I can only given an answer on the "are there other options for me" part of your question...
The use of such a complex setup for unit-tests (pulling docker images etc.) makes me suspicious:
It can mean that your tests are in fact integration tests rather than unit-tests.  Which could be perfectly fine if your goal is to find the bugs in the interactions between the involved components or in the interactions between your code and its system environment.  (The fact that your setup involves Docker images gives the impression that you intend to test your system-under-test against the system environment.)  If this is the case I wish you luck to get the other aspects of your question answered (parallelization of tests, singletons and thread safety).  Maybe it makes sense to tag your question "integration-testing" rather than "unit-testing" then, in order to attract the proper experts.
On the other hand your complex setup could be an indication that your unit-tests are not yet designed properly and/or the system under test is not yet designed to be easily testable with unit-tests: Unit-tests focus on the system-under-test in isolation - isolation from depended-on-components, but also isolation from the specifics of the system environment.  For such tests of a properly isolated system-under-test a complex setup using Docker would not be needed.
If the latter is true you could benefit from making yourself familiar with topics like "mocking", "dependency injection" or "inversion of control", which will help you to design your system-under-test and your unit test cases such that they are independent of the system environment.  Then, your complex setup would no longer be necessary and the other aspects of your question (singleton, parallelization etc.) may no longer be relevant.
Python3.6 and singletons - use case and parallel execution