Test failures
Let us now see what a test failure looks like. The following is a doctest for the is_increasing_trend
method:
def is_increasing_trend(self): """Returns True if the past three values have been strictly increasing Returns False if there have been less than three updates so far >>> stock = Stock("GOOG") >>> stock.is_increasing_trend() False """ return self.history[-3].value < \ self.history[-2].value < self.history[-1].value
The following is what we get when we run the test:
Failed example: stock.is_increasing_trend() Exception raised: Traceback (most recent call last): File "C:\Python34\lib\doctest.py", line 1324, in __run compileflags, 1), test.globs) File "<doctest __main__.Stock.is_increasing_trend[1]>", line 1, in <module> stock.is_increasing_trend() File "c:\Projects\tdd_with_python\src\stock_alerter\stock.py", line...