Skip to content

Commit

Permalink
Added coverage for the case of using last_or_default() with or with a…
Browse files Browse the repository at this point in the history
… predicate on a non-sequence such as a generator.
  • Loading branch information
rob-smallshire committed Jun 4, 2011
1 parent 7fd4d07 commit 2eb3c1b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions asq/test/test_last_or_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def test_last_or_default_predicate(self):
b = Queryable(a).last_or_default(12, lambda x: x >= 50)
self.assertEqual(b, 57)

def test_last_or_default_non_sequence_predicate(self):
def series():
yield 42
yield 45
yield 23
yield 12
a = series()
b = Queryable(a).last_or_default(37, lambda x: x > 15)
self.assertEqual(b, 23)

def test_last_or_default_predicate_empty(self):
a = []
b = Queryable(a).last_or_default(12, lambda x: x >= 50)
Expand Down

0 comments on commit 2eb3c1b

Please sign in to comment.