File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -423,19 +423,20 @@ This is a simple way to do it:
423
423
# called "normally"
424
424
...
425
425
426
- This works great, but you should be aware that there is an issue with it. If there is a pytest import anywhere
426
+ This works great, but you should be aware that there is an issue with it. If there is a pytest import anywhere
427
427
in your code flow, ``"pytest" in sys.modules `` will return True even if your code is not actually running from within a pytest run.
428
428
429
429
.. code-block :: python
430
430
431
431
import sys
432
432
433
- import pytest # unused anywhere in your code
433
+ import pytest # unused anywhere in your code
434
434
435
435
436
436
def is_called_from_test_by_pytest ():
437
437
return " pytest" in sys.modules
438
438
439
+
439
440
# is_called_from_test_by_pytest() will return True even if your code is not actually running from within a pytest run
440
441
# as there is a pytest import in your code flow
441
442
You can’t perform that action at this time.
0 commit comments