You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was able to reproduce this in a minimal reproducer:
test_problem.py:
from datetime import datetime
import unittest
from unittest.mock import Mock, patch
from freezegun import freeze_time
@freeze_time(datetime(2024, 3, 12, 12, 30))
@patch("usecase.anyfunction", Mock())
class TestProblem(unittest.TestCase):
def test_use_case(self):
pass
usecase is a module and anyfunction is a function in that module, it can be anything you want, say:
usecase.py
from fontTools import subset as ftsubset
def anyfunction():
return 5
but it has to have that import from fontTools.
and you run it with PYTHONPATH=<path_to_directory_with_your_files>/ pytest -s test_problem.py
you get the same error as above.
The problem seems to be this thing - Fonttools use timeit and in one place they do
_time = timeit.default_timer
where default_timer by default is time.perf_counter
then in a method of a class they do this, which inherently tries to add self to the perf_counter:
def reset(self, start=None):
"""Reset timer to 'start_time' or the current time."""
if start is None:
self.start = self._time()
The reason I have created it here is that it was working for fonttools with original perf_counter and really when I remove the freeze_time decorator it works fine. However once freeze_time patches it with fake_perf_counter it no longer accepts the self parameter even though the original perf_counter did.
fonttools version 4.53.1
freezegun version 1.5.1
python version 3.8.19
The text was updated successfully, but these errors were encountered:
I am getting this using pytest error:
I was able to reproduce this in a minimal reproducer:
test_problem.py:
usecase is a module and anyfunction is a function in that module, it can be anything you want, say:
usecase.py
but it has to have that import from fontTools.
and you run it with
PYTHONPATH=<path_to_directory_with_your_files>/ pytest -s test_problem.py
you get the same error as above.
The problem seems to be this thing - Fonttools use timeit and in one place they do
where default_timer by default is time.perf_counter
then in a method of a class they do this, which inherently tries to add self to the perf_counter:
The reason I have created it here is that it was working for fonttools with original perf_counter and really when I remove the freeze_time decorator it works fine. However once freeze_time patches it with fake_perf_counter it no longer accepts the self parameter even though the original perf_counter did.
fonttools version 4.53.1
freezegun version 1.5.1
python version 3.8.19
The text was updated successfully, but these errors were encountered: