Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py310 fix aio warning in ut #493

Merged
merged 8 commits into from
Feb 17, 2023

Conversation

micromoses
Copy link
Contributor

Fixing for tests/test_asyncio.py:17: DeprecationWarning: There is no current event loop.
Based on #492 , merged from #421 , and including suggested changes by @graingert

cherry against 492:

+ 6199e24c7145856f15c4d5b69c442bb6a522bd0a tests: asyncio: Fix Python 3.10 compatibility
+ 204647b305b3baab9d3f0be96afce7f6e3d4a25f Removed test as per @graingert's comment
+ c7926bda7315d22252bbbca2ca393bf37c078cc8 Changed asyncio to `run()` as per @graingert's suggestion

jktjkt and others added 8 commits October 16, 2021 18:34
Since Python 3.10, the `asyncio.get_event_loop()` has been deprecated in
favor of `asyncio.get_running_loop()`. That one, however, issues a
warning when there's no event loop running (such as in this test suite).

Fix this by always requesting a new event loop. These methods have been
available since at least Python 3.5 (and there are no older docs online
at this point).

Bug: spulec#398
Conflicts:
	.github/workflows/ci.yaml
	tox.ini
Up to python 3.10, staticmethods were not callable - so they were skipped by the condition.
Since python 3.10, staticmethods ARE callable - so adding the `isinstance(v, staticmethod)`
to the same `if` statement would consistently handle staticmethods across python
versions <=3.9 and >= 3.10.
This solves for:
```
self = <tests.test_datetimes.Tester object at 0x1073dc5e0>

    def test_class_decorator_respects_staticmethod(self):
>       assert self.helper() == datetime.date(2012, 1, 14)

tests/test_datetimes.py:453:
...
>               result = func(*args, **kwargs)
E               TypeError: Tester.helper() takes 0 positional arguments but 1 was given

freezegun/api.py:809: TypeError
```
spulec#421 (comment)
> this test can just be removed because it's the same as the above test_time_freeze_coroutine - except the syntax was hidden from 3.4 or lower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants