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

Ignore _pytest.runner by default #288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions freezegun/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ def freeze_time(time_to_freeze=None, tz_offset=0, ignore=None, tick=False, as_ar
ignore.append('selenium')
ignore.append('_pytest.terminal.')
ignore.append('_pytest.runner.')
ignore.append('_pytest.runner')

return _freeze_time(time_to_freeze, tz_offset, ignore, tick, as_arg, auto_tick_seconds)

Expand Down
15 changes: 11 additions & 4 deletions tests/test_datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
from tests import utils

from freezegun import freeze_time
from freezegun import api, freeze_time
from freezegun.api import FakeDatetime, FakeDate

try:
Expand Down Expand Up @@ -628,6 +628,16 @@ def test_time_with_nested():
assert time() == second


@pytest.fixture
def change_stack_limit():
ori_val = api.call_stack_inspection_limit
api.call_stack_inspection_limit = 100 # just to increase coverage
yield
# Restore to normal after test(s)
api.call_stack_inspection_limit = ori_val


@pytest.mark.usefixtures('change_stack_limit')
def test_should_use_real_time():
Copy link
Author

@goodspark goodspark Feb 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_should_use_real_time fails. But if I comment out the lines that change call_stack_inspection_limit, they pass.

As a sanity check, I undid my change, left the call_stack_inspection_limit lines commented out, and the tests still passed. So I'm not sure what this is doing, other than increasing coverage. Perhaps another test should be written for that instead.

I think the other tests failed (from the run from the first commit) because the limit was 'leaking' across the tests.

frozen = datetime.datetime(2015, 3, 5)
expected_frozen = 1425513600.0
Expand All @@ -636,9 +646,6 @@ def test_should_use_real_time():
expected_frozen_gmt = (2015, 3, 5, 0, 0, 0, 3, 64, -1)
expected_clock = 0

from freezegun import api
api.call_stack_inspection_limit = 100 # just to increase coverage

with freeze_time(frozen):
assert time.time() == expected_frozen
# assert time.localtime() == expected_frozen_local
Expand Down