From efd7bf72c3e51a223449336630fe50fb772e5de6 Mon Sep 17 00:00:00 2001 From: Joe Jevnik Date: Mon, 20 Jun 2016 15:16:33 -0400 Subject: [PATCH] TST: py3 compat doctests --- zipline/pipeline/visualize.py | 8 ++++---- zipline/utils/cache.py | 1 + zipline/utils/input_validation.py | 28 +++++++++++++++------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/zipline/pipeline/visualize.py b/zipline/pipeline/visualize.py index df416a2a..f0356b43 100644 --- a/zipline/pipeline/visualize.py +++ b/zipline/pipeline/visualize.py @@ -25,10 +25,10 @@ def delimit(delimiters, content): """ Surround `content` with the first and last characters of `delimiters`. - >>> delimit('[]', "foo") - u'[foo]' - >>> delimit('""', "foo") - u'"foo"' + >>> delimit('[]', "foo") # doctest: +SKIP + '[foo]' + >>> delimit('""', "foo") # doctest: +SKIP + '"foo"' """ if len(delimiters) != 2: raise ValueError( diff --git a/zipline/utils/cache.py b/zipline/utils/cache.py index f272524b..d2a9b14e 100644 --- a/zipline/utils/cache.py +++ b/zipline/utils/cache.py @@ -41,6 +41,7 @@ class CachedObject(namedtuple("_CachedObject", "value expires")): >>> obj.unwrap(expires) 1 >>> obj.unwrap(expires + Timedelta('1 minute')) + ... # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... Expired: 2014-01-01 00:00:00+00:00 diff --git a/zipline/utils/input_validation.py b/zipline/utils/input_validation.py index 7bb96b71..c94f7cfa 100644 --- a/zipline/utils/input_validation.py +++ b/zipline/utils/input_validation.py @@ -217,10 +217,11 @@ def expect_dtypes(**named): >>> foo(arange(3), 'foo') (array([0, 1, 2]), 'foo') >>> foo(arange(3, dtype=float), 'foo') # doctest: +NORMALIZE_WHITESPACE + ... # doctest: +ELLIPSIS Traceback (most recent call last): ... - TypeError: zipline.utils.input_validation.foo() expected a value with - dtype 'int64' for argument 'x', but got 'float64' instead. + TypeError: ...foo() expected a value with dtype 'int64' for argument 'x', + but got 'float64' instead. """ for name, type_ in iteritems(named): if not isinstance(type_, (dtype, tuple)): @@ -279,11 +280,11 @@ def expect_kinds(**named): 2 >>> foo(int32(2)) 2 - >>> foo(float32(2)) # doctest: +NORMALIZE_WHITESPACE + >>> foo(float32(2)) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS Traceback (most recent call last): ... - TypeError: zipline.utils.input_validation.foo() expected a numpy object of - kind 'i' for argument 'x', but got 'f' instead. + TypeError: ...foo() expected a numpy object of kind 'i' for argument 'x', + but got 'f' instead. """ for name, kind in iteritems(named): if not isinstance(kind, (str, tuple)): @@ -339,11 +340,11 @@ def expect_types(*_pos, **named): ... >>> foo(2, '3') (2, '3') - >>> foo(2.0, '3') # doctest: +NORMALIZE_WHITESPACE + >>> foo(2.0, '3') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS Traceback (most recent call last): ... - TypeError: zipline.utils.input_validation.foo() expected a value of type - int for argument 'x', but got float instead. + TypeError: ...foo() expected a value of type int for argument 'x', + but got float instead. """ if _pos: raise TypeError("expect_types() only takes keyword arguments.") @@ -466,11 +467,11 @@ def expect_element(*_pos, **named): 'A' >>> foo('b') 'B' - >>> foo('c') # doctest: +NORMALIZE_WHITESPACE + >>> foo('c') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS Traceback (most recent call last): ... - ValueError: zipline.utils.input_validation.foo() expected a value in - ('a', 'b') for argument 'x', but got 'c' instead. + ValueError: ...foo() expected a value in ('a', 'b') for argument 'x', + but got 'c' instead. Notes ----- @@ -510,10 +511,11 @@ def expect_dimensions(**dimensions): >>> foo(array([1, 1]), array([[1, 1], [2, 2]])) 2 >>> foo(array([1, 1]), array([1, 1])) # doctest: +NORMALIZE_WHITESPACE + ... # doctest: +ELLIPSIS Traceback (most recent call last): ... - ValueError: zipline.utils.input_validation.foo() expected a 2-D array for - argument 'y', but got a 1-D array instead. + ValueError: ...foo() expected a 2-D array for argument 'y', + but got a 1-D array instead. """ def _expect_dimension(expected_ndim): def _check(func, argname, argvalue):