mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 17:38:02 +00:00
@@ -102,9 +102,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -131,32 +129,30 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_format_license_key.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_format_license_key(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.format_license_key, None, None)\n",
|
||||
" self.assertRaises(TypeError, solution.format_license_key, None, None)\n",
|
||||
" license_key = '---'\n",
|
||||
" k = 3\n",
|
||||
" expected = ''\n",
|
||||
" assert_equal(solution.format_license_key(license_key, k), expected)\n",
|
||||
" self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
|
||||
" license_key = '2-4A0r7-4k'\n",
|
||||
" k = 3\n",
|
||||
" expected = '24-A0R-74K'\n",
|
||||
" assert_equal(solution.format_license_key(license_key, k), expected)\n",
|
||||
" self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
|
||||
" license_key = '2-4A0r7-4k'\n",
|
||||
" k = 4\n",
|
||||
" expected = '24A0-R74K'\n",
|
||||
" assert_equal(solution.format_license_key(license_key, k), expected)\n",
|
||||
" self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
|
||||
" print('Success: test_format_license_key')\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
@@ -194,9 +190,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
|
||||
}
|
||||
|
||||
@@ -110,9 +110,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -147,9 +145,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -161,26 +157,26 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_format_license_key.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_format_license_key(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.format_license_key, None, None)\n",
|
||||
" self.assertRaises(TypeError, solution.format_license_key, None, None)\n",
|
||||
" license_key = '---'\n",
|
||||
" k = 3\n",
|
||||
" expected = ''\n",
|
||||
" assert_equal(solution.format_license_key(license_key, k), expected)\n",
|
||||
" self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
|
||||
" license_key = '2-4A0r7-4k'\n",
|
||||
" k = 3\n",
|
||||
" expected = '24-A0R-74K'\n",
|
||||
" assert_equal(solution.format_license_key(license_key, k), expected)\n",
|
||||
" self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
|
||||
" license_key = '2-4A0r7-4k'\n",
|
||||
" k = 4\n",
|
||||
" expected = '24A0-R74K'\n",
|
||||
" assert_equal(solution.format_license_key(license_key, k), expected)\n",
|
||||
" self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
|
||||
" print('Success: test_format_license_key')\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
@@ -195,9 +191,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -228,9 +222,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,23 +1,23 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
import unittest
|
||||
|
||||
|
||||
class TestSolution(object):
|
||||
class TestSolution(unittest.TestCase):
|
||||
|
||||
def test_format_license_key(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.format_license_key, None, None)
|
||||
self.assertRaises(TypeError, solution.format_license_key, None, None)
|
||||
license_key = '---'
|
||||
k = 3
|
||||
expected = ''
|
||||
assert_equal(solution.format_license_key(license_key, k), expected)
|
||||
self.assertEqual(solution.format_license_key(license_key, k), expected)
|
||||
license_key = '2-4A0r7-4k'
|
||||
k = 3
|
||||
expected = '24-A0R-74K'
|
||||
assert_equal(solution.format_license_key(license_key, k), expected)
|
||||
self.assertEqual(solution.format_license_key(license_key, k), expected)
|
||||
license_key = '2-4A0r7-4k'
|
||||
k = 4
|
||||
expected = '24A0-R74K'
|
||||
assert_equal(solution.format_license_key(license_key, k), expected)
|
||||
self.assertEqual(solution.format_license_key(license_key, k), expected)
|
||||
print('Success: test_format_license_key')
|
||||
|
||||
def main():
|
||||
@@ -26,4 +26,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user