TST: Added doctest

This commit is contained in:
Richard Frank
2016-02-04 17:36:40 -05:00
parent 79aff84aed
commit 4e84b2c5ca
2 changed files with 21 additions and 8 deletions
+4
View File
@@ -10,6 +10,7 @@ from zipline.pipeline import (
)
from zipline.utils import (
cache,
data,
input_validation,
memoize,
numpy_utils,
@@ -78,3 +79,6 @@ class DoctestTestCase(TestCase):
def test_numpy_utils_docs(self):
self._check_docs(numpy_utils)
def test_data_docs(self):
self._check_docs(data)
+17 -8
View File
@@ -419,16 +419,25 @@ class SortedDict(MutableMapping):
>>> d[-1] = 'negative one'
>>> d[0] = 'zero'
>>> d[2] = 'two'
>>> d
SortedDict[<built-in function abs>]([(0, 'zero'), (-1, 'negative one'), (1, 'one')]) # noqa
>>> d # doctest: +NORMALIZE_WHITESPACE
SortedDict(<built-in function abs>,
[(0, 'zero'), (-1, 'negative one'), (2, 'two')])
>>> d[1] = 'one' # Mutating the mapping maintains the sort order.
>>> d # doctest: +NORMALIZE_WHITESPACE
SortedDict(<built-in function abs>,
[(0, 'zero'), (-1, 'negative one'), (1, 'one'), (2, 'two')])
>>> del d[0]
>>> d # doctest: +NORMALIZE_WHITESPACE
SortedDict(<built-in function abs>,
[(-1, 'negative one'), (1, 'one'), (2, 'two')])
>>> del d[2]
>>> d
SortedDict[<built-in function abs>]([(0, 'zero'), (-1, 'negative one'), (1, 'one')]) # noqa
SortedDict(<built-in function abs>, [(-1, 'negative one'), (1, 'one')])
"""
def __init__(self, sort_key, mapping=None, **kwargs):
def __init__(self, key, mapping=None, **kwargs):
self._map = {}
self._sorted_key_names = []
self._sort_key = sort_key
self._sort_key = key
self.update(merge(mapping or {}, kwargs))
@@ -464,8 +473,8 @@ class SortedDict(MutableMapping):
_repr_running[call_key] = 1
try:
if not self:
return '%s[%r]()' % (self.__class__.__name__, self._sort_key)
return '%s[%r](%r)' % (self.__class__.__name__, self._sort_key,
self.items())
return '%s(%r)' % (self.__class__.__name__, self._sort_key)
return '%s(%r, %r)' % (self.__class__.__name__, self._sort_key,
list(self.items()))
finally:
del _repr_running[call_key]