Skip to content

Commit 1b3b533

Browse files
committed
#273: Remove nose dependency for online_judges/
1 parent 67505c4 commit 1b3b533

File tree

60 files changed

+575
-782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+575
-782
lines changed

online_judges/assign_cookies/assign_cookies_challenge.ipynb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@
108108
{
109109
"cell_type": "code",
110110
"execution_count": null,
111-
"metadata": {
112-
"collapsed": false
113-
},
111+
"metadata": {},
114112
"outputs": [],
115113
"source": [
116114
"class Solution(object):\n",
@@ -137,25 +135,23 @@
137135
{
138136
"cell_type": "code",
139137
"execution_count": null,
140-
"metadata": {
141-
"collapsed": false
142-
},
138+
"metadata": {},
143139
"outputs": [],
144140
"source": [
145141
"# %load test_assign_cookie.py\n",
146-
"from nose.tools import assert_equal, assert_raises\n",
142+
"import unittest\n",
147143
"\n",
148144
"\n",
149-
"class TestAssignCookie(object):\n",
145+
"class TestAssignCookie(unittest.TestCase):\n",
150146
"\n",
151147
" def test_assign_cookie(self):\n",
152148
" solution = Solution()\n",
153-
" assert_raises(TypeError, solution.find_content_children, None, None)\n",
154-
" assert_equal(solution.find_content_children([1, 2, 3], \n",
149+
" self.assertRaises(TypeError, solution.find_content_children, None, None)\n",
150+
" self.assertEqual(solution.find_content_children([1, 2, 3], \n",
155151
" [1, 1]), 1)\n",
156-
" assert_equal(solution.find_content_children([1, 2], \n",
152+
" self.assertEqual(solution.find_content_children([1, 2], \n",
157153
" [1, 2, 3]), 2)\n",
158-
" assert_equal(solution.find_content_children([7, 8, 9, 10], \n",
154+
" self.assertEqual(solution.find_content_children([7, 8, 9, 10], \n",
159155
" [5, 6, 7, 8]), 2)\n",
160156
" print('Success: test_find_content_children')\n",
161157
"\n",
@@ -195,9 +191,9 @@
195191
"name": "python",
196192
"nbconvert_exporter": "python",
197193
"pygments_lexer": "ipython3",
198-
"version": "3.4.3"
194+
"version": "3.7.2"
199195
}
200196
},
201197
"nbformat": 4,
202-
"nbformat_minor": 0
198+
"nbformat_minor": 1
203199
}

online_judges/assign_cookies/assign_cookies_solution.ipynb

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@
118118
{
119119
"cell_type": "code",
120120
"execution_count": 1,
121-
"metadata": {
122-
"collapsed": false
123-
},
121+
"metadata": {},
124122
"outputs": [],
125123
"source": [
126124
"class Solution(object):\n",
@@ -153,9 +151,7 @@
153151
{
154152
"cell_type": "code",
155153
"execution_count": 2,
156-
"metadata": {
157-
"collapsed": false
158-
},
154+
"metadata": {},
159155
"outputs": [
160156
{
161157
"name": "stdout",
@@ -167,19 +163,19 @@
167163
],
168164
"source": [
169165
"%%writefile test_assign_cookie.py\n",
170-
"from nose.tools import assert_equal, assert_raises\n",
166+
"import unittest\n",
171167
"\n",
172168
"\n",
173-
"class TestAssignCookie(object):\n",
169+
"class TestAssignCookie(unittest.TestCase):\n",
174170
"\n",
175171
" def test_assign_cookie(self):\n",
176172
" solution = Solution()\n",
177-
" assert_raises(TypeError, solution.find_content_children, None, None)\n",
178-
" assert_equal(solution.find_content_children([1, 2, 3], \n",
173+
" self.assertRaises(TypeError, solution.find_content_children, None, None)\n",
174+
" self.assertEqual(solution.find_content_children([1, 2, 3], \n",
179175
" [1, 1]), 1)\n",
180-
" assert_equal(solution.find_content_children([1, 2], \n",
176+
" self.assertEqual(solution.find_content_children([1, 2], \n",
181177
" [1, 2, 3]), 2)\n",
182-
" assert_equal(solution.find_content_children([7, 8, 9, 10], \n",
178+
" self.assertEqual(solution.find_content_children([7, 8, 9, 10], \n",
183179
" [5, 6, 7, 8]), 2)\n",
184180
" print('Success: test_find_content_children')\n",
185181
"\n",
@@ -196,9 +192,7 @@
196192
{
197193
"cell_type": "code",
198194
"execution_count": 3,
199-
"metadata": {
200-
"collapsed": false
201-
},
195+
"metadata": {},
202196
"outputs": [
203197
{
204198
"name": "stdout",
@@ -229,9 +223,9 @@
229223
"name": "python",
230224
"nbconvert_exporter": "python",
231225
"pygments_lexer": "ipython3",
232-
"version": "3.4.3"
226+
"version": "3.7.2"
233227
}
234228
},
235229
"nbformat": 4,
236-
"nbformat_minor": 0
230+
"nbformat_minor": 1
237231
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestAssignCookie(object):
4+
class TestAssignCookie(unittest.TestCase):
55

66
def test_assign_cookie(self):
77
solution = Solution()
8-
assert_raises(TypeError, solution.find_content_children, None, None)
9-
assert_equal(solution.find_content_children([1, 2, 3],
8+
self.assertRaises(TypeError, solution.find_content_children, None, None)
9+
self.assertEqual(solution.find_content_children([1, 2, 3],
1010
[1, 1]), 1)
11-
assert_equal(solution.find_content_children([1, 2],
11+
self.assertEqual(solution.find_content_children([1, 2],
1212
[1, 2, 3]), 2)
13-
assert_equal(solution.find_content_children([7, 8, 9, 10],
13+
self.assertEqual(solution.find_content_children([7, 8, 9, 10],
1414
[5, 6, 7, 8]), 2)
1515
print('Success: test_find_content_children')
1616

@@ -21,4 +21,4 @@ def main():
2121

2222

2323
if __name__ == '__main__':
24-
main()
24+
main()

online_judges/busiest_period/busiest_period_challenge.ipynb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@
137137
{
138138
"cell_type": "code",
139139
"execution_count": null,
140-
"metadata": {
141-
"collapsed": false
142-
},
140+
"metadata": {},
143141
"outputs": [],
144142
"source": [
145143
"class Solution(object):\n",
@@ -166,21 +164,19 @@
166164
{
167165
"cell_type": "code",
168166
"execution_count": null,
169-
"metadata": {
170-
"collapsed": false
171-
},
167+
"metadata": {},
172168
"outputs": [],
173169
"source": [
174170
"# %load test_find_busiest_period.py\n",
175-
"from nose.tools import assert_equal, assert_raises\n",
171+
"import unittest\n",
176172
"\n",
177173
"\n",
178-
"class TestSolution(object):\n",
174+
"class TestSolution(unittest.TestCase):\n",
179175
"\n",
180176
" def test_find_busiest_period(self):\n",
181177
" solution = Solution()\n",
182-
" assert_raises(TypeError, solution.find_busiest_period, None)\n",
183-
" assert_equal(solution.find_busiest_period([]), None)\n",
178+
" self.assertRaises(TypeError, solution.find_busiest_period, None)\n",
179+
" self.assertEqual(solution.find_busiest_period([]), None)\n",
184180
" data = [\n",
185181
" Data(3, 2, EventType.EXIT),\n",
186182
" Data(1, 2, EventType.ENTER),\n",
@@ -189,7 +185,7 @@
189185
" Data(9, 2, EventType.EXIT),\n",
190186
" Data(8, 2, EventType.EXIT),\n",
191187
" ]\n",
192-
" assert_equal(solution.find_busiest_period(data), Period(7, 8))\n",
188+
" self.assertEqual(solution.find_busiest_period(data), Period(7, 8))\n",
193189
" print('Success: test_find_busiest_period')\n",
194190
"\n",
195191
"\n",
@@ -228,9 +224,9 @@
228224
"name": "python",
229225
"nbconvert_exporter": "python",
230226
"pygments_lexer": "ipython3",
231-
"version": "3.5.0"
227+
"version": "3.7.2"
232228
}
233229
},
234230
"nbformat": 4,
235-
"nbformat_minor": 0
231+
"nbformat_minor": 1
236232
}

online_judges/busiest_period/busiest_period_solution.ipynb

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@
119119
{
120120
"cell_type": "code",
121121
"execution_count": 1,
122-
"metadata": {
123-
"collapsed": false
124-
},
122+
"metadata": {},
125123
"outputs": [],
126124
"source": [
127125
"from enum import Enum\n",
@@ -160,9 +158,7 @@
160158
{
161159
"cell_type": "code",
162160
"execution_count": 2,
163-
"metadata": {
164-
"collapsed": false
165-
},
161+
"metadata": {},
166162
"outputs": [],
167163
"source": [
168164
"class Solution(object):\n",
@@ -206,9 +202,7 @@
206202
{
207203
"cell_type": "code",
208204
"execution_count": 3,
209-
"metadata": {
210-
"collapsed": false
211-
},
205+
"metadata": {},
212206
"outputs": [
213207
{
214208
"name": "stdout",
@@ -220,15 +214,15 @@
220214
],
221215
"source": [
222216
"%%writefile test_find_busiest_period.py\n",
223-
"from nose.tools import assert_equal, assert_raises\n",
217+
"import unittest\n",
224218
"\n",
225219
"\n",
226-
"class TestSolution(object):\n",
220+
"class TestSolution(unittest.TestCase):\n",
227221
"\n",
228222
" def test_find_busiest_period(self):\n",
229223
" solution = Solution()\n",
230-
" assert_raises(TypeError, solution.find_busiest_period, None)\n",
231-
" assert_equal(solution.find_busiest_period([]), None)\n",
224+
" self.assertRaises(TypeError, solution.find_busiest_period, None)\n",
225+
" self.assertEqual(solution.find_busiest_period([]), None)\n",
232226
" data = [\n",
233227
" Data(3, 2, EventType.EXIT),\n",
234228
" Data(1, 2, EventType.ENTER),\n",
@@ -237,7 +231,7 @@
237231
" Data(9, 2, EventType.EXIT),\n",
238232
" Data(8, 2, EventType.EXIT),\n",
239233
" ]\n",
240-
" assert_equal(solution.find_busiest_period(data), Period(7, 8))\n",
234+
" self.assertEqual(solution.find_busiest_period(data), Period(7, 8))\n",
241235
" print('Success: test_find_busiest_period')\n",
242236
"\n",
243237
"\n",
@@ -253,9 +247,7 @@
253247
{
254248
"cell_type": "code",
255249
"execution_count": 4,
256-
"metadata": {
257-
"collapsed": false
258-
},
250+
"metadata": {},
259251
"outputs": [
260252
{
261253
"name": "stdout",
@@ -286,9 +278,9 @@
286278
"name": "python",
287279
"nbconvert_exporter": "python",
288280
"pygments_lexer": "ipython3",
289-
"version": "3.5.0"
281+
"version": "3.7.2"
290282
}
291283
},
292284
"nbformat": 4,
293-
"nbformat_minor": 0
285+
"nbformat_minor": 1
294286
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestSolution(object):
4+
class TestSolution(unittest.TestCase):
55

66
def test_find_busiest_period(self):
77
solution = Solution()
8-
assert_raises(TypeError, solution.find_busiest_period, None)
9-
assert_equal(solution.find_busiest_period([]), None)
8+
self.assertRaises(TypeError, solution.find_busiest_period, None)
9+
self.assertEqual(solution.find_busiest_period([]), None)
1010
data = [
1111
Data(3, 2, EventType.EXIT),
1212
Data(1, 2, EventType.ENTER),
@@ -15,7 +15,7 @@ def test_find_busiest_period(self):
1515
Data(9, 2, EventType.EXIT),
1616
Data(8, 2, EventType.EXIT),
1717
]
18-
assert_equal(solution.find_busiest_period(data), Period(7, 8))
18+
self.assertEqual(solution.find_busiest_period(data), Period(7, 8))
1919
print('Success: test_find_busiest_period')
2020

2121

@@ -25,4 +25,4 @@ def main():
2525

2626

2727
if __name__ == '__main__':
28-
main()
28+
main()

online_judges/island_perimeter/island_perimeter_challenge.ipynb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@
9090
{
9191
"cell_type": "code",
9292
"execution_count": null,
93-
"metadata": {
94-
"collapsed": false
95-
},
93+
"metadata": {},
9694
"outputs": [],
9795
"source": [
9896
"class Solution(object):\n",
@@ -119,29 +117,27 @@
119117
{
120118
"cell_type": "code",
121119
"execution_count": null,
122-
"metadata": {
123-
"collapsed": false
124-
},
120+
"metadata": {},
125121
"outputs": [],
126122
"source": [
127123
"# %load test_island_perimeter.py\n",
128-
"from nose.tools import assert_equal, assert_raises\n",
124+
"import unittest\n",
129125
"\n",
130126
"\n",
131-
"class TestIslandPerimeter(object):\n",
127+
"class TestIslandPerimeter(unittest.TestCase):\n",
132128
"\n",
133129
" def test_island_perimeter(self):\n",
134130
" solution = Solution()\n",
135-
" assert_raises(TypeError, solution.island_perimeter, None)\n",
131+
" self.assertRaises(TypeError, solution.island_perimeter, None)\n",
136132
" data = [[1, 0]]\n",
137133
" expected = 4\n",
138-
" assert_equal(solution.island_perimeter(data), expected)\n",
134+
" self.assertEqual(solution.island_perimeter(data), expected)\n",
139135
" data = [[0, 1, 0, 0],\n",
140136
" [1, 1, 1, 0],\n",
141137
" [0, 1, 0, 0],\n",
142138
" [1, 1, 0, 0]]\n",
143139
" expected = 16\n",
144-
" assert_equal(solution.island_perimeter(data), expected)\n",
140+
" self.assertEqual(solution.island_perimeter(data), expected)\n",
145141
" print('Success: test_island_perimeter')\n",
146142
"\n",
147143
"\n",
@@ -180,9 +176,9 @@
180176
"name": "python",
181177
"nbconvert_exporter": "python",
182178
"pygments_lexer": "ipython3",
183-
"version": "3.5.0"
179+
"version": "3.7.2"
184180
}
185181
},
186182
"nbformat": 4,
187-
"nbformat_minor": 0
183+
"nbformat_minor": 1
188184
}

0 commit comments

Comments
 (0)