mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Fix intermittent test failure due to http happening too fast
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
# External imports
|
# External imports
|
||||||
import os
|
import os
|
||||||
import urllib2
|
import urllib2
|
||||||
|
import time
|
||||||
|
|
||||||
# Internal imports
|
# Internal imports
|
||||||
import vcr
|
import vcr
|
||||||
@@ -25,13 +26,16 @@ def test_disk_saver_nowrite(tmpdir):
|
|||||||
assert last_mod == last_mod2
|
assert last_mod == last_mod2
|
||||||
|
|
||||||
def test_disk_saver_write(tmpdir):
|
def test_disk_saver_write(tmpdir):
|
||||||
'''Ensure that when you close a cassette with changing it it does rewrite the file'''
|
'''Ensure that when you close a cassette after changing it it does rewrite the file'''
|
||||||
fname = str(tmpdir.join('synopsis.yaml'))
|
fname = str(tmpdir.join('synopsis.yaml'))
|
||||||
with vcr.use_cassette(fname) as cass:
|
with vcr.use_cassette(fname) as cass:
|
||||||
urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
assert cass.play_count == 0
|
assert cass.play_count == 0
|
||||||
last_mod = os.path.getmtime(fname)
|
last_mod = os.path.getmtime(fname)
|
||||||
|
|
||||||
|
time.sleep(1) # Make sure at least 1 second passes, otherwise sometimes
|
||||||
|
# the mtime doesn't change
|
||||||
|
|
||||||
with vcr.use_cassette(fname) as cass:
|
with vcr.use_cassette(fname) as cass:
|
||||||
urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
urllib2.urlopen('http://httpbin.org/').read()
|
urllib2.urlopen('http://httpbin.org/').read()
|
||||||
|
|||||||
Reference in New Issue
Block a user