From 2e85e087682c9da6559b56df486670f33e4a2d25 Mon Sep 17 00:00:00 2001 From: Andrew Daniels Date: Thu, 8 Oct 2015 14:35:00 -0400 Subject: [PATCH] TST: Adds basic test coverage for FutureChain.__iter__ --- tests/test_assets.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_assets.py b/tests/test_assets.py index c7fde844..a34292c7 100644 --- a/tests/test_assets.py +++ b/tests/test_assets.py @@ -888,6 +888,18 @@ class TestFutureChain(TestCase): cl = FutureChain(self.asset_finder, lambda: '2006-02-01', 'CL') self.assertEqual(cl[-1], 3) + def test_iter(self): + """ Test the __iter__ method of FutureChain. + """ + cl = FutureChain(self.asset_finder, lambda: '2005-12-01', 'CL') + for i, contract in enumerate(cl): + self.assertEqual(contract, i) + + # First contract is now invalid, so sids will be offset by one + cl = FutureChain(self.asset_finder, lambda: '2005-12-21', 'CL') + for i, contract in enumerate(cl): + self.assertEqual(contract, i + 1) + def test_root_symbols(self): """ Test that different variations on root symbols are handled as expected.