mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-09 09:40:36 +08:00
TST: Updated modified time of market data in test_examples
This commit is contained in:
committed by
Freddie Vargus
parent
440ff4205b
commit
731e3a8678
@@ -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
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user