def test_default(self): filter_iter = seqfilter.length_filter(self.seqs) self.assertIsInstance(filter_iter, types.GeneratorType) filtrate = list(filter_iter) self.assertEqual(len(filtrate), len(self.seqs)) self.assertEqual(self.seqs, filtrate)
def test_no_filtrate(self): filtrate = list(seqfilter.length_filter(self.seqs, 9, 10)) self.assertEqual([], filtrate) filtrate = list(seqfilter.length_filter(self.seqs, 0, 3)) self.assertEqual([], filtrate)
def test_limit_error(self): f = seqfilter.length_filter([], 6, 5) self.assertRaises(ValueError, f.next)
def test_equal_min_max(self): filtrate = list(seqfilter.length_filter(self.seqs, 6, 6)) self.assertEqual(len(filtrate), 1) self.assertTrue(filtrate[0] is self.seqs[2])
def test_empty_iter(self): filtrate = list(seqfilter.length_filter([])) self.assertEqual([], filtrate)
def test_no_max(self): for i in range(4, 9): filtrate = list(seqfilter.length_filter(self.seqs, i)) self.assertEqual(len(filtrate), 9-i)
def test_no_min(self): for i in range(4, 9): filtrate = list(seqfilter.length_filter(self.seqs, max_length=i)) self.assertEqual(len(filtrate), i-3)
def test_no_filter_limit(self): filtrate = list(seqfilter.length_filter(self.seqs, 4, 8)) self.assertEqual(len(filtrate), len(self.seqs)) self.assertEqual(self.seqs, filtrate)
def test_no_min(self): for i in range(4, 9): filtrate = list(seqfilter.length_filter(self.seqs, max_length=i)) self.assertEqual(len(filtrate), i - 3)
def test_no_max(self): for i in range(4, 9): filtrate = list(seqfilter.length_filter(self.seqs, i)) self.assertEqual(len(filtrate), 9 - i)