Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac686a1

Browse files
author
Siddharta Govindaraj
committed
nose2 - parametrised tests
1 parent 3fb38fd commit ac686a1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

stock_alerter/tests/test_stock.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import collections
33
from datetime import datetime, timedelta
44

5+
from nose2.tools.params import params
6+
57
from ..stock import Stock, StockSignal
68

79

@@ -21,6 +23,24 @@ def test_price_of_a_new_stock_class_should_be_None():
2123
test_price_of_a_new_stock_class_should_be_None.teardown = teardown_test
2224

2325

26+
def given_a_series_of_prices(stock, prices):
27+
timestamps = [datetime(2014, 2, 10), datetime(2014, 2, 11),
28+
datetime(2014, 2, 12), datetime(2014, 2, 13)]
29+
for timestamp, price in zip(timestamps, prices):
30+
stock.update(timestamp, price)
31+
32+
33+
@params(
34+
([8, 10, 12], True),
35+
([8, 12, 10], False),
36+
([8, 10, 10], False)
37+
)
38+
def test_stock_trends(prices, expected_output):
39+
goog = Stock("GOOG")
40+
given_a_series_of_prices(goog, prices)
41+
assert goog.is_increasing_trend() == expected_output
42+
43+
2444
class StockTest(unittest.TestCase):
2545
def setUp(self):
2646
self.goog = Stock("GOOG")

0 commit comments

Comments
 (0)