#273: Remove nose dependency for recursion_dynamic/ (#280)

This commit is contained in:
Donne Martin
2020-07-13 21:26:50 -04:00
committed by GitHub
parent dce6b6aa67
commit 76cb6507fc
57 changed files with 548 additions and 751 deletions

View File

@@ -124,9 +124,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class StockTrader(object):\n",
@@ -153,45 +151,41 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_max_profit.py\n",
"from nose.tools import assert_equal\n",
"from nose.tools import assert_raises\n",
"from nose.tools import assert_true\n",
"import unittest\n",
"\n",
"\n",
"class TestMaxProfit(object):\n",
"class TestMaxProfit(unittest.TestCase):\n",
"\n",
" def test_max_profit(self):\n",
" stock_trader = StockTrader()\n",
" assert_raises(TypeError, stock_trader.find_max_profit, None, None)\n",
" assert_equal(stock_trader.find_max_profit(prices=[], k=0), [])\n",
" self.assertRaises(TypeError, stock_trader.find_max_profit, None, None)\n",
" self.assertEqual(stock_trader.find_max_profit(prices=[], k=0), [])\n",
" prices = [5, 4, 3, 2, 1]\n",
" k = 3\n",
" assert_equal(stock_trader.find_max_profit(prices, k), (0, []))\n",
" self.assertEqual(stock_trader.find_max_profit(prices, k), (0, []))\n",
" prices = [2, 5, 7, 1, 4, 3, 1, 3]\n",
" profit, transactions = stock_trader.find_max_profit(prices, k)\n",
" assert_equal(profit, 10)\n",
" assert_true(Transaction(Type.SELL,\n",
" self.assertEqual(profit, 10)\n",
" self.assertTrue(Transaction(Type.SELL,\n",
" day=7,\n",
" price=3) in transactions)\n",
" assert_true(Transaction(Type.BUY,\n",
" self.assertTrue(Transaction(Type.BUY,\n",
" day=6,\n",
" price=1) in transactions)\n",
" assert_true(Transaction(Type.SELL,\n",
" self.assertTrue(Transaction(Type.SELL,\n",
" day=4,\n",
" price=4) in transactions)\n",
" assert_true(Transaction(Type.BUY,\n",
" self.assertTrue(Transaction(Type.BUY,\n",
" day=3,\n",
" price=1) in transactions)\n",
" assert_true(Transaction(Type.SELL,\n",
" self.assertTrue(Transaction(Type.SELL,\n",
" day=2,\n",
" price=7) in transactions)\n",
" assert_true(Transaction(Type.BUY,\n",
" self.assertTrue(Transaction(Type.BUY,\n",
" day=0,\n",
" price=2) in transactions)\n",
" print('Success: test_max_profit')\n",
@@ -232,9 +226,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}