CloverHealth / pytest-pgsql

Clean PostgreSQL Databases for Your Tests
http://pytest-pgsql.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
65 stars 4 forks source link

doc: uses non-existing postgresql.time.freeze #22

Open blueyed opened 3 years ago

blueyed commented 3 years ago

In https://github.com/CloverHealth/pytest-pgsql/blob/15c99b8ad65a2746970f148c7efb7a9cc8caabcf/docs/index.rst#manipulating-time it has:

with postgresql.time.freeze('December 31st 1999 11:59:59 PM') as freezer:
    # Time is frozen inside the database *and* Python.
    …

That should probably be with pytest_pgsql.freeze_time.

It's also in the docs.

Happy to do a PR, but wasn't sure if that was meant really. (the example code then also should have an import probably to make things clearer)

dargueta commented 3 years ago

~Oops! Yes, please feel free to open a PR with the correction.~

@vskr's solution is correct. @blueyed if you could open a PR to change that to postgresql_db instead of postgresql that'd be awesome.

vskr commented 3 years ago

pytest_pgsql.freeze_time is not a context manager. Can we use with pytest_pgsql.freeze_time

How can we advance(tick or set advance time) using pytest_pgsql.freeze_time. Thanks!

vskr commented 3 years ago

I think postgresql_db or transacted_postgresl_db can be used as context managers. This is how I got it to work for anyone interested in the future:

    with transacted_postgresql_db.time.freeze('December 31st 1999 11:59:59 PM') as freezer:
            freezer.tick()