From 45adc572673af6e35928b3d9425092d7e016f15c Mon Sep 17 00:00:00 2001 From: Stewart Douglas Date: Thu, 10 Sep 2015 10:30:01 -0400 Subject: [PATCH] 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. --- tests/test_examples.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 67d83975..5c93547b 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -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)