Skip to content

Commit 27abd41

Browse files
committed
Make doctest regression test friendly
1 parent 8a16289 commit 27abd41

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

stock_alerter/readme.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ are going to be processed. A simple dictionary will do.
99
>>> from stock_alerter.stock import Stock
1010
>>> exchange = {"GOOG": Stock("GOOG"), "AAPL": Stock("AAPL")}
1111
>>> for key in sorted(exchange.keys()):
12-
... print(key, exchange[key])
12+
... print(key, str(exchange[key]))
1313
...
14-
AAPL <stock_alerter.stock.Stock object at 0x0...>
15-
GOOG <stock_alerter.stock.Stock object at 0x0...>
14+
AAPL Stock("AAPL")
15+
GOOG Stock("GOOG")
1616

1717
Next, we configure the reader. The reader is the source from where the
1818
stock updates are coming. The module provides two readers out of the

stock_alerter/stock.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def __init__(self, symbol):
2020
self.history = TimeSeries()
2121
self.updated = Event()
2222

23+
def __str__(self):
24+
class_name = type(self).__name__
25+
return '{}("{}")'.format(class_name, self.symbol)
26+
2327
@property
2428
def price(self):
2529
"""Returns the current price of the Stock

0 commit comments

Comments
 (0)