コード例 #1
0
 def function_should_return_a_generator(self):
     expect(type(fibonacci_sequence(1))).to.equal(GeneratorType)
コード例 #2
0
 def shouldnt_allow(self, limit_type):
     gen = fibonacci_sequence(limit_type)
     expect(next, [gen]).to.raise_a(TypeError)
コード例 #3
0
 def shouldnt_allow_a_limit_less_than_one(self):
     gen = fibonacci_sequence(0)
     expect(next, [gen]).to.raise_a(ValueError)
コード例 #4
0
 def shouldnt_allow_negative_numbers(self):
     gen = fibonacci_sequence(-1)
     expect(next, [gen]).to.raise_a(ValueError)
コード例 #5
0
 def can_generate_the(self, limit, value):
     sequence = [num for num in fibonacci_sequence(limit)]
     expect(len(sequence)).to.equal(limit)
     expect(sequence[-1]).to.equal(value)