question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test failures on Python 3.8

See original GitHub issue

Hi. I’m bootstrapping Python 3.8 in Fedora and I got stuck at freezegun, it has build fialures. Those are reproducible here, on master.

$ git rev-parse HEAD
9347d133f33f675c87bb0569d70d9d95abef737f
$ tox -e py38
GLOB sdist-make: .../freezegun/setup.py
py38 inst-nodeps: .../freezegun/.tox/dist/freezegun-0.3.11.zip
py38 installed: atomicwrites==1.3.0,attrs==19.1.0,certifi==2019.3.9,chardet==3.0.4,coverage==4.5.3,coveralls==1.7.0,dateparser==0.7.1,docopt==0.6.2,freezegun==0.3.11,humanize==0.5.1,idna==2.8,maya==0.6.1,mock==2.0.0,more-itertools==6.0.0,pbr==5.1.3,pendulum==2.0.4,pluggy==0.9.0,py==1.8.0,pytest==3.10.1,pytest-cov==2.6.1,pytest-cover==3.0.0,pytest-coverage==0.0,python-dateutil==2.8.0,pytz==2018.9,pytzdata==2018.9,regex==2019.3.12,requests==2.21.0,six==1.12.0,snaptime==0.2.4,tzlocal==1.5.1,urllib3==1.24.1
py38 run-test-pre: PYTHONHASHSEED='905734949'
py38 runtests: commands[0] | make test NOSE_ARGS=
rm -f .coverage
pytest
============================= test session starts ==============================
platform linux -- Python 3.8.0a2, pytest-3.10.1, py-1.8.0, pluggy-0.9.0
rootdir: .../freezegun, inifile:
plugins: cov-2.6.1
collected 105 items

tests/test_asyncio.py ..                                                 [  1%]
tests/test_class_import.py ..............                                [ 15%]
tests/test_datetimes.py ..................................s............. [ 60%]
..........                                                               [ 70%]
tests/test_errors.py ..                                                  [ 72%]
tests/test_import_alias.py ...                                           [ 75%]
tests/test_operations.py .........                                       [ 83%]
tests/test_pickle.py ...                                                 [ 86%]
tests/test_sqlite3.py ..                                                 [ 88%]
tests/test_ticking.py ......                                             [ 94%]
tests/test_utils.py ..                                                   [ 96%]
tests/test_uuid.py FF                                                    [ 98%]
tests/test_warnings.py ..                                                [100%]

=================================== FAILURES ===================================
______________________________ test_uuid1_future _______________________________

    def test_uuid1_future():
        """
        Test that we can go back in time after setting a future date.
        Normally UUID1 would disallow this, since it keeps track of
        the _last_timestamp, but we override that now.
        """
        future_target = datetime.datetime(2056, 2, 6, 14, 3, 21)
        with freeze_time(future_target):
>           assert time_from_uuid(uuid.uuid1()) == future_target
E           AssertionError: assert FakeDatetime(2019, 3, 28, 9, 59, 29, 624778) == datetime.datetime(2056, 2, 6, 14, 3, 21)
E            +  where FakeDatetime(2019, 3, 28, 9, 59, 29, 624778) = time_from_uuid(UUID('2d98abed-5140-11e9-af9c-e86a64040576'))
E            +    where UUID('2d98abed-5140-11e9-af9c-e86a64040576') = <function uuid1 at 0x7fe23a36b5c0>()
E            +      where <function uuid1 at 0x7fe23a36b5c0> = uuid.uuid1

tests/test_uuid.py:26: AssertionError
_______________________________ test_uuid1_past ________________________________

    def test_uuid1_past():
        """
        Test that we can go forward in time after setting some time in the past.
        This is simply the opposite of test_uuid1_future()
        """
        past_target = datetime.datetime(1978, 7, 6, 23, 6, 31)
        with freeze_time(past_target):
>           assert time_from_uuid(uuid.uuid1()) == past_target
E           AssertionError: assert FakeDatetime(2019, 3, 28, 9, 59, 29, 664840) == datetime.datetime(1978, 7, 6, 23, 6, 31)
E            +  where FakeDatetime(2019, 3, 28, 9, 59, 29, 664840) = time_from_uuid(UUID('2d9ec8d5-5140-11e9-b7ca-e86a64040576'))
E            +    where UUID('2d9ec8d5-5140-11e9-b7ca-e86a64040576') = <function uuid1 at 0x7fe23a36b5c0>()
E            +      where <function uuid1 at 0x7fe23a36b5c0> = uuid.uuid1

tests/test_uuid.py:40: AssertionError
=============================== warnings summary ===============================
.tox/py38/lib/python3.8/site-packages/dateparser/date.py:320
  .../freezegun/.tox/py38/lib/python3.8/site-packages/dateparser/date.py:320: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    if not isinstance(languages, (list, tuple, collections.Set)) and languages is not None:

tests/test_datetimes.py::test_should_use_real_time
  .../freezegun/freezegun/api.py:207: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
    return real_clock()

tests/test_ticking.py::test_ticking_time_clock
  .../freezegun/freezegun/api.py:210: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
    return 0.0 if not tick_flags[-1] else real_clock()
  .../freezegun/freezegun/api.py:219: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
    total_seconds += real_clock()
  .../freezegun/freezegun/api.py:219: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
    total_seconds += real_clock()
  .../freezegun/freezegun/api.py:219: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
    total_seconds += real_clock()
  .../freezegun/freezegun/api.py:219: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
    total_seconds += real_clock()

-- Docs: https://docs.pytest.org/en/latest/warnings.html
========= 2 failed, 102 passed, 1 skipped, 7 warnings in 0.74 seconds ==========
make: *** [Makefile:9: test] Error 1
ERROR: InvocationError for command '/usr/bin/make test NOSE_ARGS=' (exited with code 2)
___________________________________ summary ____________________________________
ERROR:   py38: commands failed

There are also some Python 3.8 deprecation warnings.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
tirkarthicommented, May 13, 2019

time.clock is now removed in 3.8 : https://github.com/python/cpython/pull/13270/

3reactions
pgansslecommented, Jun 19, 2019

@tirkarthi How about something like:

_NEEDS_TIME_NS = hasattr(time, 'time_ns')

For the feature gate?

I think getattr(time, 'time_ns', None) will also work if, since this supports Python 2.7, you want to avoid hasattr, but I think it’s safe to use hasattr in this case since it’s a standard library module in Python 2.7 and thus not likely to change to something where hasattr will cause problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tests failing on Python 3.8 · Issue #100 - GitHub
Since the release of Python 3.8, the tests have started failing, even though they were passing on early releases of Python 3.8.
Read more >
Issue 39326: Python-3.8.1 "test_importlib" failed - Issue Tracker
Python -3.8.1 after "make test" command in Ubuntu terminal report an error saying "test_importlib" failed. = Tests result: FAILURE then ...
Read more >
Coverage unittest fails in Python 3.8 - Stack Overflow
my_func.func1 and it runs normally. Now, I am trying to implement some unittest functions in ./project/scripts/tests . To do ...
Read more >
Unit test failures in Python 3.8 / Debian Sid - StoryBoard
python-octaviaclient fails to build when running unit tests. ... Thomas Goirand created the task "Unit test failures in Python 3.8 / Debian Sid"...
Read more >
#3394 (Fix test failures on tahoe --version and Python 3.7 and 3.8 ...
The project fails to install on Python 3.7+. I recommend the project should install even on unsupported environments, allowing for testing on those ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found