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

Mock time to make date-based tests reliable #394

Merged
merged 2 commits into from
Mar 16, 2020

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Mar 10, 2020

Use mocked clock when running tests involving checking the 'Date'
header. These tests used system clock so far which caused frequent
test failures if the check occurred in the second following generating
the response.

Fixes #376

@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

Merging #394 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #394   +/-   ##
======================================
  Coverage    84.8%   84.8%           
======================================
  Files           6       6           
  Lines         849     849           
  Branches      129     129           
======================================
  Hits          720     720           
  Misses         87      87           
  Partials       42      42

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8c4b8b...4e00ff1. Read the comment docs.

@@ -64,10 +66,11 @@ def test_httpretty_provides_easy_access_to_querystrings(now):


@httprettified
@within(two=microseconds)
def test_httpretty_should_mock_headers_httplib2(now):
@patch('httpretty.core.datetime')
Copy link
Owner

Choose a reason for hiding this comment

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

this would be better with freezegun

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Use mocked clock when running tests involving checking the 'Date'
header.  These tests used system clock so far which caused frequent
test failures if the check occurred in the second following generating
the response.

Fixes gabrielfalcao#376
@mgorny
Copy link
Contributor Author

mgorny commented Mar 16, 2020

Ping.

@gabrielfalcao
Copy link
Owner

great job!

@gabrielfalcao gabrielfalcao merged commit af6ed59 into gabrielfalcao:master Mar 16, 2020
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.

test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2 fails when clock not in sync with GitHub
2 participants