def test_summary(self): items = range(100) out = StringIO() seq = st.seqtimer(items, output=out, summary=True) for (idx, item) in enumerate(seq): self.assertEqual(items[idx], item) self.assertTrue("Finished processing" in out.getvalue())
def test_warns(self): out = StringIO() seq = st.seqtimer(iter(range(10)), output=out, summary=False, length=1) with patch_object(st.warnings, 'warn') as warn: for (idx, item) in enumerate(seq): pass self.assertTrue(warn.called)
def test_passthrough(self): items = range(100) out = StringIO() seq = st.seqtimer(items, items=10, output=out, summary=False) for (idx, item) in enumerate(seq): self.assertEqual(items[idx], item) self.assertEqual(len(out.getvalue().split("\n")), 11)