pytest-dev / pytest-dev/pytest-libfaketime
Off by a microsecond
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Perhaps not the worst thing in the world, but when I updated to 0.1.3, I found I was off by a single microsecond in my test.
I was doing something like
with fake_time('1970-01-01 00:00:07.012')
and in my test, datetime.now() would end up returning a time that represented 1970-01-01 00:00:07.011999
And later, I am testing a certain time has elapsed, but I would have to account for this single microsecond to be off. I am also plugged in with the latest of these dependencies
pytest-cov==5.0.0
pytest-env==1.1.3
pytest-libfaketime==0.1.2
pytest-mock==3.14.0
pytest==8.2.1
pytest-xdist[psutil]==3.6.1
These are not all inclusive of everything in my setup, but hopefully of is enough to help identify any issues. Running in a docker environment with the docker container python:3.8.6 and setting up these environment variables within my Dockerfile
ENV LD_LIBRARY_PATH="/usr/local/lib/python3.8/site-packages/libfaketime/vendor/libfaketime/src"
ENV LD_PRELOAD="libfaketime.so.1"
ENV DONT_FAKE_MONOTONIC="1"
ENV FAKETIME_DID_REEXEC=true
ENV FAKETIME_NO_CACHE="1"
A clue maybe: There may be some pytest-xdist conflict issue. Not everyone on my team was seeing this same problem, and we did not have pytest-xdist pinned to a version, so we may have been on different versions. Trying to put everything to the latest version, available today, and I see this issue with the time being off by 1 microsecond.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with Python 3.8.6, pytest-libfaketime 0.1.2, pytest-xdist, and the listed libfaketime environment variables in the Docker setup. Compare datetime.now() under fake_time('1970-01-01 00:00:07.012') with and without pytest-xdist, then identify a reproducible cause and verify that the reported one-microsecond discrepancy is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100