mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
@@ -116,10 +116,10 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_search_sorted_matrix.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSortedMatrix(object):\n",
|
||||
"class TestSortedMatrix(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_find_val(self):\n",
|
||||
" matrix = [[20, 40, 63, 80],\n",
|
||||
@@ -127,9 +127,9 @@
|
||||
" [40, 60, 110, 110],\n",
|
||||
" [50, 65, 105, 150]]\n",
|
||||
" sorted_matrix = SortedMatrix()\n",
|
||||
" assert_raises(TypeError, sorted_matrix.find_val, None, None)\n",
|
||||
" assert_equal(sorted_matrix.find_val(matrix, 1000), None)\n",
|
||||
" assert_equal(sorted_matrix.find_val(matrix, 60), (2, 1))\n",
|
||||
" self.assertRaises(TypeError, sorted_matrix.find_val, None, None)\n",
|
||||
" self.assertEqual(sorted_matrix.find_val(matrix, 1000), None)\n",
|
||||
" self.assertEqual(sorted_matrix.find_val(matrix, 60), (2, 1))\n",
|
||||
" print('Success: test_find_val')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -168,7 +168,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.4"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -107,9 +107,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class SortedMatrix(object):\n",
|
||||
@@ -139,24 +137,22 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Writing test_search_sorted_matrix.py\n"
|
||||
"Overwriting test_search_sorted_matrix.py\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_search_sorted_matrix.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSortedMatrix(object):\n",
|
||||
"class TestSortedMatrix(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_find_val(self):\n",
|
||||
" matrix = [[20, 40, 63, 80],\n",
|
||||
@@ -164,9 +160,9 @@
|
||||
" [40, 60, 110, 110],\n",
|
||||
" [50, 65, 105, 150]]\n",
|
||||
" sorted_matrix = SortedMatrix()\n",
|
||||
" assert_raises(TypeError, sorted_matrix.find_val, None, None)\n",
|
||||
" assert_equal(sorted_matrix.find_val(matrix, 1000), None)\n",
|
||||
" assert_equal(sorted_matrix.find_val(matrix, 60), (2, 1))\n",
|
||||
" self.assertRaises(TypeError, sorted_matrix.find_val, None, None)\n",
|
||||
" self.assertEqual(sorted_matrix.find_val(matrix, 1000), None)\n",
|
||||
" self.assertEqual(sorted_matrix.find_val(matrix, 60), (2, 1))\n",
|
||||
" print('Success: test_find_val')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -182,9 +178,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -215,9 +209,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
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
import unittest
|
||||
|
||||
|
||||
class TestSortedMatrix(object):
|
||||
class TestSortedMatrix(unittest.TestCase):
|
||||
|
||||
def test_find_val(self):
|
||||
matrix = [[20, 40, 63, 80],
|
||||
@@ -9,9 +9,9 @@ class TestSortedMatrix(object):
|
||||
[40, 60, 110, 110],
|
||||
[50, 65, 105, 150]]
|
||||
sorted_matrix = SortedMatrix()
|
||||
assert_raises(TypeError, sorted_matrix.find_val, None, None)
|
||||
assert_equal(sorted_matrix.find_val(matrix, 1000), None)
|
||||
assert_equal(sorted_matrix.find_val(matrix, 60), (2, 1))
|
||||
self.assertRaises(TypeError, sorted_matrix.find_val, None, None)
|
||||
self.assertEqual(sorted_matrix.find_val(matrix, 1000), None)
|
||||
self.assertEqual(sorted_matrix.find_val(matrix, 60), (2, 1))
|
||||
print('Success: test_find_val')
|
||||
|
||||
|
||||
@@ -21,4 +21,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user