TST: Updated modified time of market data in test_examples

This commit is contained in:
Freddie Vargus
2017-06-06 17:09:23 -04:00
committed by Freddie Vargus
parent 440ff4205b
commit 731e3a8678
2 changed files with 23 additions and 3 deletions
+6 -2
View File
@@ -25,7 +25,7 @@ from zipline.testing import test_resource_path
from zipline.testing.fixtures import WithTmpDir, ZiplineTestCase
from zipline.testing.predicates import assert_equal
from zipline.utils.cache import dataframe_cache
from zipline.utils.paths import ensure_file
from zipline.utils.paths import update_modified_time
# Otherwise the next line sometimes complains about being run too late.
@@ -57,7 +57,11 @@ class ExamplesTests(WithTmpDir, ZiplineTestCase):
market_data = ('SPY_benchmark.csv', 'treasury_curves.csv')
for data in market_data:
ensure_file(cls.tmpdir.getpath('example_data/root/data/' + data))
update_modified_time(
cls.tmpdir.getpath(
'example_data/root/data/' + data
)
)
@parameterized.expand(sorted(examples.EXAMPLE_MODULES))
def test_example(self, example_name):
+17 -1
View File
@@ -48,7 +48,7 @@ def ensure_directory_containing(path):
def ensure_file(path):
"""
Ensure that a file exists. This will create any parent directories needed
and create an empty file if it does not exists.
and create an empty file if it does not exist.
Parameters
----------
@@ -59,6 +59,22 @@ def ensure_file(path):
open(path, 'a+').close() # touch the file
def update_modified_time(path, times=None):
"""
Updates the modified time of an existing file. This will create any
parent directories needed and create an empty file if it does not exist.
Parameters
----------
path : str
The file path to update.
times : tuple
A tuple of size two; access time and modified time
"""
ensure_directory_containing(path)
os.utime(path, times)
def last_modified_time(path):
"""
Get the last modified time of path as a Timestamp.