mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-07 09:58:03 +00:00
@@ -98,9 +98,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -123,9 +121,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -137,19 +133,19 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_is_power_of_two.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_is_power_of_two(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
|
||||
" assert_equal(solution.is_power_of_two(0), False)\n",
|
||||
" assert_equal(solution.is_power_of_two(1), True)\n",
|
||||
" assert_equal(solution.is_power_of_two(2), True)\n",
|
||||
" assert_equal(solution.is_power_of_two(15), False)\n",
|
||||
" assert_equal(solution.is_power_of_two(16), True)\n",
|
||||
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(0), False)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(1), True)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(2), True)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(15), False)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(16), True)\n",
|
||||
" print('Success: test_is_power_of_two')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -165,9 +161,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -198,9 +192,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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user