BUG: Remove set_trace and add test coverage.

This commit is contained in:
Scott Sanderson
2016-09-20 17:46:27 -04:00
parent c28ac1a4a5
commit 9cc2ecf8d5
2 changed files with 13 additions and 3 deletions
+13 -2
View File
@@ -23,7 +23,6 @@ import pandas as pd
from six import iteritems
from six.moves import range, map
from zipline.testing import parameter_space
import zipline.utils.events
from zipline.utils.calendars import get_calendar
from zipline.utils.events import (
@@ -454,13 +453,25 @@ class StatelessRulesTests(RuleTestCase):
rule_type(n=3.0) # Should trigger a warning about float coercion.
self.assertEqual(len(raised_warnings), 1)
warning_str = raised_warnings[0].message.message
# We only implicitly convert from float to int when there's no loss of
# precision.
with self.assertRaises(TypeError):
rule_type(3.1)
def test_invalid_offsets(self):
with self.assertRaises(ValueError):
NthTradingDayOfWeek(5)
with self.assertRaises(ValueError):
NthTradingDayOfWeek(-1)
with self.assertRaises(ValueError):
NthTradingDayOfMonth(-1)
with self.assertRaises(ValueError):
NthTradingDayOfMonth(24)
class StatefulRulesTests(RuleTestCase):
CALENDAR_STRING = "NYSE"
-1
View File
@@ -434,7 +434,6 @@ class TradingDayOfWeekRule(six.with_metaclass(ABCMeta, StatelessRule)):
@preprocess(n=lossless_float_to_int('TradingDayOfWeekRule'))
def __init__(self, n, invert):
if not 0 <= n < MAX_WEEK_RANGE:
import nose.tools; nose.tools.set_trace()
raise _out_of_range_error(MAX_WEEK_RANGE)
self.td_delta = (-n - 1) if invert else n