sdispater / pendulum

Python datetimes made easy
https://pendulum.eustace.io
MIT License
6.12k stars 372 forks source link

"import pendulum" causes unwanted import of pytest (presence of pytest in sys.modules often used to control Python behaviour) #808

Open tomjridge opened 4 months ago

tomjridge commented 4 months ago

Issue

The following code:

python -c "import sys; import pendulum; print('pytest' in sys.modules)"

prints True. Unfortunately the test 'pytest' in sys.modules is often used to detect whether code is running under pytest or not, and modify code behaviour accordingly (see eg https://pypi.org/project/pytest-is-running/)

Ideally importing pendlum would not cause pytest to be imported.

Is this possible to fix easily?

Thanks for the great work on pendulum!

tomjridge commented 4 months ago

Seems to be caused by the pypi package "time-machine"