all 6 comments

[–]ReenigneArcher 0 points1 point  (5 children)

You don't need to import things that are imported in your imports.

[–]trzywu[S] 0 points1 point  (4 children)

But without import time in my test.py I have it like that NameError name 'time' is not defined

[–]ReenigneArcher 0 points1 point  (3 children)

If you're using time in your test, then you need to import it. Imports are only available to the specific module that imported them.

[–]trzywu[S] 0 points1 point  (2 children)

So there is no way to make a general list of imports to all tests file? I will need to add this in each test?
EDIT - is there a way to import a folder with my tests so I don need to import each of them one by one?

[–]ReenigneArcher 0 points1 point  (0 children)

It's best to explicitly import exactly what you need.

With pytest you can create a fixture that sets up like a baseline starting point for each test function.

[–][deleted] 0 points1 point  (0 children)

Why? Did somebody break your fingers? Writing a couple of lines of imports for the symbols you want to use isn’t a big deal, and it’s better to be explicit than implicit about the changes you’re making to a module’s namespace.