#273: Remove nose dependency for graphs_trees/ (#277)

This commit is contained in:
Donne Martin
2020-07-10 21:02:32 -04:00
committed by GitHub
parent 139e157250
commit abf7524c26
67 changed files with 860 additions and 1027 deletions

View File

@@ -136,14 +136,14 @@
"outputs": [],
"source": [
"# %load test_bst_second_largest.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestBstSecondLargest(object):\n",
"class TestBstSecondLargest(unittest.TestCase):\n",
"\n",
" def test_bst_second_largest(self):\n",
" bst = Solution(None)\n",
" assert_raises(TypeError, bst.find_second_largest)\n",
" self.assertRaises(TypeError, bst.find_second_largest)\n",
" root = Node(10)\n",
" bst = Solution(root)\n",
" node5 = bst.insert(5)\n",
@@ -155,13 +155,13 @@
" node2 = bst.insert(2)\n",
" node4 = bst.insert(4)\n",
" node30 = bst.insert(30)\n",
" assert_equal(bst.find_second_largest(), node20)\n",
" self.assertEqual(bst.find_second_largest(), node20)\n",
" root = Node(10)\n",
" bst = Solution(root)\n",
" node5 = bst.insert(5)\n",
" node3 = bst.insert(3)\n",
" node7 = bst.insert(7)\n",
" assert_equal(bst.find_second_largest(), node7)\n",
" self.assertEqual(bst.find_second_largest(), node7)\n",
" print('Success: test_bst_second_largest')\n",
"\n",
"\n",
@@ -200,7 +200,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.7.2"
}
},
"nbformat": 4,

View File

@@ -124,9 +124,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%run ../bst/bst.py"
@@ -135,9 +133,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(Bst):\n",
@@ -175,9 +171,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -189,14 +183,14 @@
],
"source": [
"%%writefile test_bst_second_largest.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestBstSecondLargest(object):\n",
"class TestBstSecondLargest(unittest.TestCase):\n",
"\n",
" def test_bst_second_largest(self):\n",
" bst = Solution(None)\n",
" assert_raises(TypeError, bst.find_second_largest)\n",
" self.assertRaises(TypeError, bst.find_second_largest)\n",
" root = Node(10)\n",
" bst = Solution(root)\n",
" node5 = bst.insert(5)\n",
@@ -208,13 +202,13 @@
" node2 = bst.insert(2)\n",
" node4 = bst.insert(4)\n",
" node30 = bst.insert(30)\n",
" assert_equal(bst.find_second_largest(), node20)\n",
" self.assertEqual(bst.find_second_largest(), node20)\n",
" root = Node(10)\n",
" bst = Solution(root)\n",
" node5 = bst.insert(5)\n",
" node3 = bst.insert(3)\n",
" node7 = bst.insert(7)\n",
" assert_equal(bst.find_second_largest(), node7)\n",
" self.assertEqual(bst.find_second_largest(), node7)\n",
" print('Success: test_bst_second_largest')\n",
"\n",
"\n",
@@ -230,9 +224,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -263,9 +255,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
}

View File

@@ -1,11 +1,11 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestBstSecondLargest(object):
class TestBstSecondLargest(unittest.TestCase):
def test_bst_second_largest(self):
bst = Solution(None)
assert_raises(TypeError, bst.find_second_largest)
self.assertRaises(TypeError, bst.find_second_largest)
root = Node(10)
bst = Solution(root)
node5 = bst.insert(5)
@@ -17,13 +17,13 @@ class TestBstSecondLargest(object):
node2 = bst.insert(2)
node4 = bst.insert(4)
node30 = bst.insert(30)
assert_equal(bst.find_second_largest(), node20)
self.assertEqual(bst.find_second_largest(), node20)
root = Node(10)
bst = Solution(root)
node5 = bst.insert(5)
node3 = bst.insert(3)
node7 = bst.insert(7)
assert_equal(bst.find_second_largest(), node7)
self.assertEqual(bst.find_second_largest(), node7)
print('Success: test_bst_second_largest')
@@ -33,4 +33,4 @@ def main():
if __name__ == '__main__':
main()
main()