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

bpo-31066: Fix test_httpservers.test_last_modified() #2933

Merged
merged 1 commit into from
Jul 28, 2017
Merged
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
10 changes: 6 additions & 4 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,11 @@ def setUp(self):
self.tempdir = tempfile.mkdtemp(dir=basetempdir)
self.tempdir_name = os.path.basename(self.tempdir)
self.base_url = '/' + self.tempdir_name
with open(os.path.join(self.tempdir, 'test'), 'wb') as temp:
tempname = os.path.join(self.tempdir, 'test')
with open(tempname, 'wb') as temp:
temp.write(self.data)
mtime = os.fstat(temp.fileno()).st_mtime
temp.flush()
mtime = os.stat(tempname).st_mtime
# compute last modification datetime for browser cache tests
last_modif = datetime.datetime.fromtimestamp(mtime,
datetime.timezone.utc)
Expand Down Expand Up @@ -471,7 +473,7 @@ def test_browser_cache(self):
headers['If-Modified-Since'] = email.utils.format_datetime(new_dt,
usegmt=True)
response = self.request(self.base_url + '/test', headers=headers)
self.check_status_and_reason(response, HTTPStatus.NOT_MODIFIED)
self.check_status_and_reason(response, HTTPStatus.NOT_MODIFIED)

def test_browser_cache_file_changed(self):
# with If-Modified-Since earlier than Last-Modified, must return 200
Expand All @@ -491,7 +493,7 @@ def test_browser_cache_with_If_None_Match_header(self):
headers['If-Modified-Since'] = self.last_modif_header
headers['If-None-Match'] = "*"
response = self.request(self.base_url + '/test', headers=headers)
self.check_status_and_reason(response, HTTPStatus.OK)
self.check_status_and_reason(response, HTTPStatus.OK)

def test_invalid_requests(self):
response = self.request('/', method='FOO')
Expand Down