#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

@@ -75,9 +75,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class SelectionSort(object):\n",
@@ -101,30 +99,28 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_selection_sort.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSelectionSort(object):\n",
"class TestSelectionSort(unittest.TestCase):\n",
"\n",
" def test_selection_sort(self, func):\n",
" print('None input')\n",
" assert_raises(TypeError, func, None)\n",
" self.assertRaises(TypeError, func, None)\n",
"\n",
" print('Empty input')\n",
" assert_equal(func([]), [])\n",
" self.assertEqual(func([]), [])\n",
"\n",
" print('One element')\n",
" assert_equal(func([5]), [5])\n",
" self.assertEqual(func([5]), [5])\n",
"\n",
" print('Two or more elements')\n",
" data = [5, 1, 7, 2, 6, -3, 5, 7, -10]\n",
" assert_equal(func(data), sorted(data))\n",
" self.assertEqual(func(data), sorted(data))\n",
"\n",
" print('Success: test_selection_sort\\n')\n",
"\n",
@@ -172,9 +168,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

@@ -95,9 +95,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"class SelectionSort(object):\n",
@@ -164,9 +162,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -178,24 +174,24 @@
],
"source": [
"%%writefile test_selection_sort.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSelectionSort(object):\n",
"class TestSelectionSort(unittest.TestCase):\n",
"\n",
" def test_selection_sort(self, func):\n",
" print('None input')\n",
" assert_raises(TypeError, func, None)\n",
" self.assertRaises(TypeError, func, None)\n",
"\n",
" print('Empty input')\n",
" assert_equal(func([]), [])\n",
" self.assertEqual(func([]), [])\n",
"\n",
" print('One element')\n",
" assert_equal(func([5]), [5])\n",
" self.assertEqual(func([5]), [5])\n",
"\n",
" print('Two or more elements')\n",
" data = [5, 1, 7, 2, 6, -3, 5, 7, -10]\n",
" assert_equal(func(data), sorted(data))\n",
" self.assertEqual(func(data), sorted(data))\n",
"\n",
" print('Success: test_selection_sort\\n')\n",
"\n",
@@ -220,9 +216,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -262,9 +256,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

@@ -1,21 +1,21 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestSelectionSort(object):
class TestSelectionSort(unittest.TestCase):
def test_selection_sort(self, func):
print('None input')
assert_raises(TypeError, func, None)
self.assertRaises(TypeError, func, None)
print('Empty input')
assert_equal(func([]), [])
self.assertEqual(func([]), [])
print('One element')
assert_equal(func([5]), [5])
self.assertEqual(func([5]), [5])
print('Two or more elements')
data = [5, 1, 7, 2, 6, -3, 5, 7, -10]
assert_equal(func(data), sorted(data))
self.assertEqual(func(data), sorted(data))
print('Success: test_selection_sort\n')
@@ -34,4 +34,4 @@ def main():
if __name__ == '__main__':
main()
main()