Skip to content

Off by a microsecond #2

@life4u2c

Description

@life4u2c

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions