No need to add example as the explanation of the issue is simple.
nbdev_test uses up to 8 workers (threads) to run the tests, if we have a library called new_lib for example that its __init__ file has some global variables in it, if we have more than 8 tests, there will be a worker that will run more than one test, and because all the tests do import new_lib, that worker that runs more than one test won't import new_lib again and give the new test a fresh new environment as new_lib is already in sys.modules so because of Python caching modules it won't be imported again.
you should do something that refreshes workers before assigning them new tests
No need to add example as the explanation of the issue is simple. nbdev_test uses up to 8 workers (threads) to run the tests, if we have a library called new_lib for example that its
__init__
file has some global variables in it, if we have more than 8 tests, there will be a worker that will run more than one test, and because all the tests do import new_lib, that worker that runs more than one test won't import new_lib again and give the new test a fresh new environment as new_lib is already in sys.modules so because of Python caching modules it won't be imported again. you should do something that refreshes workers before assigning them new tests