#273: Remove nose dependency for online_judges/ (#282)

This commit is contained in:
Donne Martin
2020-07-14 21:34:08 -04:00
committed by GitHub
parent 67505c49b2
commit 46d3939632
60 changed files with 575 additions and 782 deletions

View File

@@ -135,9 +135,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@@ -164,34 +162,32 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_count_sentence_fit.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSolution(object):\n",
"class TestSolution(unittest.TestCase):\n",
"\n",
" def test_count_sentence_fit(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.count_sentence_fit, \n",
" self.assertRaises(TypeError, solution.count_sentence_fit, \n",
" None, None, None)\n",
" assert_raises(ValueError, solution.count_sentence_fit, \n",
" self.assertRaises(ValueError, solution.count_sentence_fit, \n",
" 'abc', rows=-1, cols=-1)\n",
" sentence = [\"hello\", \"world\"]\n",
" expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=2, cols=8),\n",
" self.assertEqual(solution.count_sentence_fit(sentence, rows=2, cols=8),\n",
" expected)\n",
" sentence = [\"a\", \"bcd\", \"e\"]\n",
" expected = 2\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=3, cols=6),\n",
" self.assertEqual(solution.count_sentence_fit(sentence, rows=3, cols=6),\n",
" expected)\n",
" sentence = [\"I\", \"had\", \"apple\", \"pie\"]\n",
" expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=4, cols=5),\n",
" self.assertEqual(solution.count_sentence_fit(sentence, rows=4, cols=5),\n",
" expected)\n",
" print('Success: test_count_sentence_fit')\n",
"\n",
@@ -231,9 +227,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

@@ -153,9 +153,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@@ -228,9 +226,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -242,28 +238,28 @@
],
"source": [
"%%writefile test_count_sentence_fit.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSolution(object):\n",
"class TestSolution(unittest.TestCase):\n",
"\n",
" def test_count_sentence_fit(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.count_sentence_fit, \n",
" self.assertRaises(TypeError, solution.count_sentence_fit, \n",
" None, None, None)\n",
" assert_raises(ValueError, solution.count_sentence_fit, \n",
" self.assertRaises(ValueError, solution.count_sentence_fit, \n",
" 'abc', rows=-1, cols=-1)\n",
" sentence = [\"hello\", \"world\"]\n",
" expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=2, cols=8),\n",
" self.assertEqual(solution.count_sentence_fit(sentence, rows=2, cols=8),\n",
" expected)\n",
" sentence = [\"a\", \"bcd\", \"e\"]\n",
" expected = 2\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=3, cols=6),\n",
" self.assertEqual(solution.count_sentence_fit(sentence, rows=3, cols=6),\n",
" expected)\n",
" sentence = [\"I\", \"had\", \"apple\", \"pie\"]\n",
" expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=4, cols=5),\n",
" self.assertEqual(solution.count_sentence_fit(sentence, rows=4, cols=5),\n",
" expected)\n",
" print('Success: test_count_sentence_fit')\n",
"\n",
@@ -280,9 +276,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -313,9 +307,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,25 +1,25 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestSolution(object):
class TestSolution(unittest.TestCase):
def test_count_sentence_fit(self):
solution = Solution()
assert_raises(TypeError, solution.count_sentence_fit,
self.assertRaises(TypeError, solution.count_sentence_fit,
None, None, None)
assert_raises(ValueError, solution.count_sentence_fit,
self.assertRaises(ValueError, solution.count_sentence_fit,
'abc', rows=-1, cols=-1)
sentence = ["hello", "world"]
expected = 1
assert_equal(solution.count_sentence_fit(sentence, rows=2, cols=8),
self.assertEqual(solution.count_sentence_fit(sentence, rows=2, cols=8),
expected)
sentence = ["a", "bcd", "e"]
expected = 2
assert_equal(solution.count_sentence_fit(sentence, rows=3, cols=6),
self.assertEqual(solution.count_sentence_fit(sentence, rows=3, cols=6),
expected)
sentence = ["I", "had", "apple", "pie"]
expected = 1
assert_equal(solution.count_sentence_fit(sentence, rows=4, cols=5),
self.assertEqual(solution.count_sentence_fit(sentence, rows=4, cols=5),
expected)
print('Success: test_count_sentence_fit')
@@ -30,4 +30,4 @@ def main():
if __name__ == '__main__':
main()
main()