mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-11 11:16:15 +08:00
TST: Simulate running an algo using scripts/run_algo.py
Previously we have not had test coverage of the parse_args() or run_pipeline() functions invoked when running scripts/run_algo.py.
This commit is contained in:
+10
-1
@@ -26,6 +26,8 @@ from nose_parameterized import parameterized
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from zipline.utils import parse_args, run_pipeline
|
||||
|
||||
# Otherwise the next line sometimes complains about being run too late.
|
||||
_multiprocess_can_split_ = False
|
||||
|
||||
@@ -39,8 +41,15 @@ def example_dir():
|
||||
|
||||
|
||||
class ExamplesTests(TestCase):
|
||||
# Test algorithms as if they being executed directly from the command line.
|
||||
# Test algorithms as if they are executed directly from the command line.
|
||||
@parameterized.expand(((os.path.basename(f).replace('.', '_'), f) for f in
|
||||
glob.glob(os.path.join(example_dir(), '*.py'))))
|
||||
def test_example(self, name, example):
|
||||
imp.load_source('__main__', os.path.basename(example), open(example))
|
||||
|
||||
# Test algorithm as if scripts/run_algo.py is being used.
|
||||
def test_example_run_pipline(self):
|
||||
example = os.path.join(example_dir(), 'buyapple.py')
|
||||
confs = ['-f', example, '--start', '2011-1-1', '--end', '2012-1-1']
|
||||
parsed_args = parse_args(confs)
|
||||
run_pipeline(**parsed_args)
|
||||
|
||||
Reference in New Issue
Block a user