#273: Remove nose dependency for sorting_searching/ (#278)

This commit is contained in:
Donne Martin
2020-07-11 11:25:26 -04:00
committed by GitHub
parent abf7524c26
commit d488e4f355
30 changed files with 257 additions and 333 deletions

View File

@@ -108,18 +108,18 @@
"outputs": [],
"source": [
"# %load test_radix_sort.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestRadixSort(object):\n",
"class TestRadixSort(unittest.TestCase):\n",
"\n",
" def test_sort(self):\n",
" radix_sort = RadixSort()\n",
" assert_raises(TypeError, radix_sort.sort, None)\n",
" assert_equal(radix_sort.sort([]), [])\n",
" self.assertRaises(TypeError, radix_sort.sort, None)\n",
" self.assertEqual(radix_sort.sort([]), [])\n",
" array = [128, 256, 164, 8, 2, 148, 212, 242, 244]\n",
" expected = [2, 8, 128, 148, 164, 212, 242, 244, 256]\n",
" assert_equal(radix_sort.sort(array), expected)\n",
" self.assertEqual(radix_sort.sort(array), expected)\n",
" print('Success: test_sort')\n",
"\n",
"\n",
@@ -158,7 +158,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.7.2"
}
},
"nbformat": 4,

View File

@@ -115,9 +115,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class RadixSort(object):\n",
@@ -150,9 +148,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -164,18 +160,18 @@
],
"source": [
"%%writefile test_radix_sort.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestRadixSort(object):\n",
"class TestRadixSort(unittest.TestCase):\n",
"\n",
" def test_sort(self):\n",
" radix_sort = RadixSort()\n",
" assert_raises(TypeError, radix_sort.sort, None)\n",
" assert_equal(radix_sort.sort([]), [])\n",
" self.assertRaises(TypeError, radix_sort.sort, None)\n",
" self.assertEqual(radix_sort.sort([]), [])\n",
" array = [128, 256, 164, 8, 2, 148, 212, 242, 244]\n",
" expected = [2, 8, 128, 148, 164, 212, 242, 244, 256]\n",
" assert_equal(radix_sort.sort(array), expected)\n",
" self.assertEqual(radix_sort.sort(array), expected)\n",
" print('Success: test_sort')\n",
"\n",
"\n",
@@ -191,9 +187,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -224,9 +218,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,15 +1,15 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestRadixSort(object):
class TestRadixSort(unittest.TestCase):
def test_sort(self):
radix_sort = RadixSort()
assert_raises(TypeError, radix_sort.sort, None)
assert_equal(radix_sort.sort([]), [])
self.assertRaises(TypeError, radix_sort.sort, None)
self.assertEqual(radix_sort.sort([]), [])
array = [128, 256, 164, 8, 2, 148, 212, 242, 244]
expected = [2, 8, 128, 148, 164, 212, 242, 244, 256]
assert_equal(radix_sort.sort(array), expected)
self.assertEqual(radix_sort.sort(array), expected)
print('Success: test_sort')
@@ -19,4 +19,4 @@ def main():
if __name__ == '__main__':
main()
main()