Merge pull request #1289 from quantopian/wildcard

wildcard object and doctests
This commit is contained in:
Richard Frank
2016-06-22 18:09:57 -04:00
committed by GitHub
22 changed files with 139 additions and 146 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ def to_dict(l):
Example
-------
>>> to_dict([2, 3, 4])
>>> to_dict([2, 3, 4]) # doctest: +SKIP
{'0': 2, '1': 3, '2': 4}
"""
return dict(zip(map(str, range(len(l))), l))
@@ -1,3 +1,4 @@
#!/usr/bin/env python
#
# Copyright 2013 Quantopian, Inc.
#
+4 -4
View File
@@ -3046,7 +3046,7 @@ class TestAccountControls(WithDataPortal, WithSimParams, ZiplineTestCase):
# format(i, actual_position, expected_positions[i]))
class TestFutureFlip(WithSimParams, WithDataPortal, ZiplineTestCase):
class TestFutureFlip(WithDataPortal, WithSimParams, ZiplineTestCase):
START_DATE = pd.Timestamp('2006-01-09', tz='utc')
END_DATE = pd.Timestamp('2006-01-10', tz='utc')
sid, = ASSET_FINDER_EQUITY_SIDS = (1,)
@@ -3057,8 +3057,8 @@ class TestFutureFlip(WithSimParams, WithDataPortal, ZiplineTestCase):
{
cls.sid: factory.create_trade_history(
cls.sid,
[1, 2, 4],
[1e9, 1e9, 1e9],
[1, 2],
[1e9, 1e9],
timedelta(days=1),
cls.sim_params,
cls.trading_schedule,
@@ -3067,7 +3067,7 @@ class TestFutureFlip(WithSimParams, WithDataPortal, ZiplineTestCase):
index=cls.sim_params.trading_days,
)
@skip
@skip('broken in zipline 1.0.0')
def test_flip_algo(self):
metadata = {1: {'symbol': 'TEST',
'start_date': self.sim_params.trading_days[0],
-91
View File
@@ -1,91 +0,0 @@
from __future__ import print_function
import sys
import doctest
from unittest import TestCase
from zipline import testing
from zipline.lib import adjustment, normalize
from zipline.pipeline import (
engine,
expression,
)
from zipline.utils import (
cache,
data,
functional,
input_validation,
memoize,
numpy_utils,
preprocess,
)
class DoctestTestCase(TestCase):
@classmethod
def setUpClass(cls):
import pdb
# Workaround for the issue addressed by this (unmerged) PR to pdbpp:
# https://bitbucket.org/antocuni/pdb/pull-request/40/fix-ensure_file_can_write_unicode/diff # noqa
if '_pdbpp_path_hack' in pdb.__file__:
cls._skip = True
else:
cls._skip = False
cls.flags = doctest.REPORT_CDIFF | doctest.IGNORE_EXCEPTION_DETAIL
def _check_docs(self, module):
if self._skip:
# Printing this directly to __stdout__ so that it doesn't get
# captured by nose.
print("Warning: Skipping doctests for %s because "
"pdbpp is installed." % module.__name__, file=sys.__stdout__)
return
try:
doctest.testmod(
module,
verbose=True,
raise_on_error=True,
optionflags=self.flags,
)
except doctest.UnexpectedException as e:
raise e.exc_info[1]
except doctest.DocTestFailure as e:
print("Got:")
print(e.got)
raise
def test_adjustment_docs(self):
self._check_docs(adjustment)
def test_expression_docs(self):
self._check_docs(expression)
def test_engine_docs(self):
self._check_docs(engine)
def test_memoize_docs(self):
self._check_docs(memoize)
def test_testing_docs(self):
self._check_docs(testing)
def test_preprocess_docs(self):
self._check_docs(preprocess)
def test_input_validation_docs(self):
self._check_docs(input_validation)
def test_cache_docs(self):
self._check_docs(cache)
def test_numpy_utils_docs(self):
self._check_docs(numpy_utils)
def test_data_docs(self):
self._check_docs(data)
def test_functional_docs(self):
self._check_docs(functional)
def test_normalize_docs(self):
self._check_docs(normalize)