#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

@@ -111,9 +111,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class GraphShortestPath(Graph):\n",
@@ -140,16 +138,14 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_shortest_path.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestShortestPath(object):\n",
"class TestShortestPath(unittest.TestCase):\n",
"\n",
" def test_shortest_path(self):\n",
" nodes = []\n",
@@ -165,9 +161,9 @@
" graph.add_edge(3, 2)\n",
" graph.add_edge(3, 4)\n",
"\n",
" assert_equal(graph.shortest_path(nodes[0].key, nodes[2].key), [0, 1, 3, 2])\n",
" assert_equal(graph.shortest_path(nodes[0].key, nodes[0].key), [0])\n",
" assert_equal(graph.shortest_path(nodes[4].key, nodes[5].key), None)\n",
" self.assertEqual(graph.shortest_path(nodes[0].key, nodes[2].key), [0, 1, 3, 2])\n",
" self.assertEqual(graph.shortest_path(nodes[0].key, nodes[0].key), [0])\n",
" self.assertEqual(graph.shortest_path(nodes[4].key, nodes[5].key), None)\n",
"\n",
" print('Success: test_shortest_path')\n",
"\n",
@@ -207,9 +203,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@@ -116,9 +116,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%run ../graph/graph.py"
@@ -127,9 +125,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from collections import deque\n",
@@ -181,9 +177,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -195,10 +189,10 @@
],
"source": [
"%%writefile test_shortest_path.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestShortestPath(object):\n",
"class TestShortestPath(unittest.TestCase):\n",
"\n",
" def test_shortest_path(self):\n",
" nodes = []\n",
@@ -214,9 +208,9 @@
" graph.add_edge(3, 2)\n",
" graph.add_edge(3, 4)\n",
"\n",
" assert_equal(graph.shortest_path(nodes[0].key, nodes[2].key), [0, 1, 3, 2])\n",
" assert_equal(graph.shortest_path(nodes[0].key, nodes[0].key), [0])\n",
" assert_equal(graph.shortest_path(nodes[4].key, nodes[5].key), None)\n",
" self.assertEqual(graph.shortest_path(nodes[0].key, nodes[2].key), [0, 1, 3, 2])\n",
" self.assertEqual(graph.shortest_path(nodes[0].key, nodes[0].key), [0])\n",
" self.assertEqual(graph.shortest_path(nodes[4].key, nodes[5].key), None)\n",
"\n",
" print('Success: test_shortest_path')\n",
"\n",
@@ -233,9 +227,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -266,9 +258,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,7 +1,7 @@
from nose.tools import assert_equal
import unittest
class TestShortestPath(object):
class TestShortestPath(unittest.TestCase):
def test_shortest_path(self):
nodes = []
@@ -17,9 +17,9 @@ class TestShortestPath(object):
graph.add_edge(3, 2)
graph.add_edge(3, 4)
assert_equal(graph.shortest_path(nodes[0].key, nodes[2].key), [0, 1, 3, 2])
assert_equal(graph.shortest_path(nodes[0].key, nodes[0].key), [0])
assert_equal(graph.shortest_path(nodes[4].key, nodes[5].key), None)
self.assertEqual(graph.shortest_path(nodes[0].key, nodes[2].key), [0, 1, 3, 2])
self.assertEqual(graph.shortest_path(nodes[0].key, nodes[0].key), [0])
self.assertEqual(graph.shortest_path(nodes[4].key, nodes[5].key), None)
print('Success: test_shortest_path')
@@ -30,4 +30,4 @@ def main():
if __name__ == '__main__':
main()
main()