def test_pop_empty_fail(self): ''' Test that popping from an empty buffer results in RuntimeException being raised along with "Buffer empty" exception message ''' with pytest.raises(RuntimeError) as excinfo: random_size = random.randrange(1, 100) buffer = RingBuffer(random_size) buffer.pop() self.assertEqual(str(excinfo.value), 'Buffer is empty!')
def test_pop(self): ''' Test that buffer pop returns pushed value ''' random_size = random.randrange(1, 100) buffer = RingBuffer(random_size) buffer.push(0) returned_element = buffer.pop() self.assertEqual(returned_element, 0)