Skip to content

Commit b598f47

Browse files
authored
#273: Remove nose dependency for arrays_strings/ (#274)
1 parent 9678c5e commit b598f47

34 files changed

+399
-481
lines changed

arrays_strings/compress/compress_challenge.ipynb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@
7676
{
7777
"cell_type": "code",
7878
"execution_count": null,
79-
"metadata": {
80-
"collapsed": false
81-
},
79+
"metadata": {},
8280
"outputs": [],
8381
"source": [
8482
"class CompressString(object):\n",
@@ -107,24 +105,22 @@
107105
{
108106
"cell_type": "code",
109107
"execution_count": null,
110-
"metadata": {
111-
"collapsed": false
112-
},
108+
"metadata": {},
113109
"outputs": [],
114110
"source": [
115111
"# %load test_compress.py\n",
116-
"from nose.tools import assert_equal\n",
112+
"import unittest\n",
117113
"\n",
118114
"\n",
119-
"class TestCompress(object):\n",
115+
"class TestCompress(unittest.TestCase):\n",
120116
"\n",
121117
" def test_compress(self, func):\n",
122-
" assert_equal(func(None), None)\n",
123-
" assert_equal(func(''), '')\n",
124-
" assert_equal(func('AABBCC'), 'AABBCC')\n",
125-
" assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E')\n",
126-
" assert_equal(func('BAAACCDDDD'), 'BA3C2D4')\n",
127-
" assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4')\n",
118+
" self.assertEqual(func(None), None)\n",
119+
" self.assertEqual(func(''), '')\n",
120+
" self.assertEqual(func('AABBCC'), 'AABBCC')\n",
121+
" self.assertEqual(func('AAABCCDDDDE'), 'A3BC2D4E')\n",
122+
" self.assertEqual(func('BAAACCDDDD'), 'BA3C2D4')\n",
123+
" self.assertEqual(func('AAABAACCDDDD'), 'A3BA2C2D4')\n",
128124
" print('Success: test_compress')\n",
129125
"\n",
130126
"\n",
@@ -164,9 +160,9 @@
164160
"name": "python",
165161
"nbconvert_exporter": "python",
166162
"pygments_lexer": "ipython3",
167-
"version": "3.5.0"
163+
"version": "3.7.2"
168164
}
169165
},
170166
"nbformat": 4,
171-
"nbformat_minor": 0
167+
"nbformat_minor": 1
172168
}

arrays_strings/compress/compress_solution.ipynb

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@
9292
{
9393
"cell_type": "code",
9494
"execution_count": 1,
95-
"metadata": {
96-
"collapsed": false
97-
},
95+
"metadata": {},
9896
"outputs": [],
9997
"source": [
10098
"class CompressString(object):\n",
@@ -129,9 +127,7 @@
129127
{
130128
"cell_type": "code",
131129
"execution_count": 2,
132-
"metadata": {
133-
"collapsed": false
134-
},
130+
"metadata": {},
135131
"outputs": [
136132
{
137133
"name": "stdout",
@@ -143,18 +139,18 @@
143139
],
144140
"source": [
145141
"%%writefile test_compress.py\n",
146-
"from nose.tools import assert_equal\n",
142+
"import unittest\n",
147143
"\n",
148144
"\n",
149-
"class TestCompress(object):\n",
145+
"class TestCompress(unittest.TestCase):\n",
150146
"\n",
151147
" def test_compress(self, func):\n",
152-
" assert_equal(func(None), None)\n",
153-
" assert_equal(func(''), '')\n",
154-
" assert_equal(func('AABBCC'), 'AABBCC')\n",
155-
" assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E')\n",
156-
" assert_equal(func('BAAACCDDDD'), 'BA3C2D4')\n",
157-
" assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4')\n",
148+
" self.assertEqual(func(None), None)\n",
149+
" self.assertEqual(func(''), '')\n",
150+
" self.assertEqual(func('AABBCC'), 'AABBCC')\n",
151+
" self.assertEqual(func('AAABCCDDDDE'), 'A3BC2D4E')\n",
152+
" self.assertEqual(func('BAAACCDDDD'), 'BA3C2D4')\n",
153+
" self.assertEqual(func('AAABAACCDDDD'), 'A3BA2C2D4')\n",
158154
" print('Success: test_compress')\n",
159155
"\n",
160156
"\n",
@@ -171,9 +167,7 @@
171167
{
172168
"cell_type": "code",
173169
"execution_count": 3,
174-
"metadata": {
175-
"collapsed": false
176-
},
170+
"metadata": {},
177171
"outputs": [
178172
{
179173
"name": "stdout",
@@ -204,9 +198,9 @@
204198
"name": "python",
205199
"nbconvert_exporter": "python",
206200
"pygments_lexer": "ipython3",
207-
"version": "3.5.0"
201+
"version": "3.7.2"
208202
}
209203
},
210204
"nbformat": 4,
211-
"nbformat_minor": 0
205+
"nbformat_minor": 1
212206
}

arrays_strings/compress/test_compress.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
from nose.tools import assert_equal
1+
import unittest
22

33

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

66
def test_compress(self, func):
7-
assert_equal(func(None), None)
8-
assert_equal(func(''), '')
9-
assert_equal(func('ABC'), 'ABC')
10-
assert_equal(func('AABBCC'), 'AABBCC')
11-
assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E')
12-
assert_equal(func('BAAACCDDDD'), 'BA3C2D4')
13-
assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4')
7+
self.assertEqual(func(None), None)
8+
self.assertEqual(func(''), '')
9+
self.assertEqual(func('AABBCC'), 'AABBCC')
10+
self.assertEqual(func('AAABCCDDDDE'), 'A3BC2D4E')
11+
self.assertEqual(func('BAAACCDDDD'), 'BA3C2D4')
12+
self.assertEqual(func('AAABAACCDDDD'), 'A3BA2C2D4')
1413
print('Success: test_compress')
1514

1615

arrays_strings/compress_alt/better_compress_challenge.ipynb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@
7676
{
7777
"cell_type": "code",
7878
"execution_count": null,
79-
"metadata": {
80-
"collapsed": false
81-
},
79+
"metadata": {},
8280
"outputs": [],
8381
"source": [
8482
"def compress_string(string):\n",
@@ -105,22 +103,24 @@
105103
{
106104
"cell_type": "code",
107105
"execution_count": null,
108-
"metadata": {
109-
"collapsed": false
110-
},
106+
"metadata": {},
111107
"outputs": [],
112108
"source": [
113109
"# %load test_compress.py\n",
114-
"from nose.tools import assert_equal\n",
110+
"import unittest\n",
115111
"\n",
116112
"\n",
117-
"class TestCompress(object):\n",
113+
"class TestCompress(unittest.TestCase):\n",
118114
"\n",
119115
" def test_compress(self, func):\n",
120-
" assert_equal(func(None), None)\n",
121-
" assert_equal(func(''), '')\n",
122-
" assert_equal(func('AABBCC'), 'AABBCC')\n",
123-
" assert_equal(func('AAABCCDDDD'), 'A3BCCD4')\n",
116+
" self.assertEqual(func(None), None)\n",
117+
" self.assertEqual(func(''), '')\n",
118+
" self.assertEqual(func('AABBCC'), 'AABBCC')\n",
119+
" self.assertEqual(func('AAABCCDDDD'), 'A3BCCD4')\n",
120+
" self.assertEqual(\n",
121+
" func('aaBCCEFFFFKKMMMMMMP taaammanlaarrrr seeeeeeeeek tooo'),\n",
122+
" 'aaBCCEF4KKM6P ta3mmanlaar4 se9k to3',\n",
123+
" )\n",
124124
" print('Success: test_compress')\n",
125125
"\n",
126126
"\n",
@@ -159,9 +159,9 @@
159159
"name": "python",
160160
"nbconvert_exporter": "python",
161161
"pygments_lexer": "ipython3",
162-
"version": "3.5.0"
162+
"version": "3.7.2"
163163
}
164164
},
165165
"nbformat": 4,
166-
"nbformat_minor": 0
166+
"nbformat_minor": 1
167167
}

arrays_strings/compress_alt/better_compress_solution.ipynb

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"This notebook was prepared by [hashhar](https://github.com/hashhar), second solution added by [janhak] (https://github.com/janhak). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
7+
"This notebook was prepared by [hashhar](https://github.com/hashhar), second solution added by [janhak](https://github.com/janhak). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
88
]
99
},
1010
{
@@ -103,10 +103,8 @@
103103
},
104104
{
105105
"cell_type": "code",
106-
"execution_count": null,
107-
"metadata": {
108-
"collapsed": false
109-
},
106+
"execution_count": 1,
107+
"metadata": {},
110108
"outputs": [],
111109
"source": [
112110
"def compress_string(string):\n",
@@ -200,10 +198,8 @@
200198
},
201199
{
202200
"cell_type": "code",
203-
"execution_count": null,
204-
"metadata": {
205-
"collapsed": true
206-
},
201+
"execution_count": 2,
202+
"metadata": {},
207203
"outputs": [],
208204
"source": [
209205
"def split_to_blocks(string):\n",
@@ -239,24 +235,33 @@
239235
},
240236
{
241237
"cell_type": "code",
242-
"execution_count": null,
243-
"metadata": {
244-
"collapsed": false
245-
},
246-
"outputs": [],
238+
"execution_count": 3,
239+
"metadata": {},
240+
"outputs": [
241+
{
242+
"name": "stdout",
243+
"output_type": "stream",
244+
"text": [
245+
"Overwriting test_compress.py\n"
246+
]
247+
}
248+
],
247249
"source": [
248250
"%%writefile test_compress.py\n",
249-
"from nose.tools import assert_equal\n",
251+
"import unittest\n",
250252
"\n",
251253
"\n",
252-
"class TestCompress(object):\n",
254+
"class TestCompress(unittest.TestCase):\n",
253255
"\n",
254256
" def test_compress(self, func):\n",
255-
" assert_equal(func(None), None)\n",
256-
" assert_equal(func(''), '')\n",
257-
" assert_equal(func('AABBCC'), 'AABBCC')\n",
258-
" assert_equal(func('AAABCCDDDD'), 'A3BCCD4')\n",
259-
" assert_equal(func('aaBCCEFFFFKKMMMMMMP taaammanlaarrrr seeeeeeeeek tooo'), 'aaBCCEF4KKM6P ta3mmanlaar4 se9k to3')\n",
257+
" self.assertEqual(func(None), None)\n",
258+
" self.assertEqual(func(''), '')\n",
259+
" self.assertEqual(func('AABBCC'), 'AABBCC')\n",
260+
" self.assertEqual(func('AAABCCDDDD'), 'A3BCCD4')\n",
261+
" self.assertEqual(\n",
262+
" func('aaBCCEFFFFKKMMMMMMP taaammanlaarrrr seeeeeeeeek tooo'),\n",
263+
" 'aaBCCEF4KKM6P ta3mmanlaar4 se9k to3',\n",
264+
" )\n",
260265
" print('Success: test_compress')\n",
261266
"\n",
262267
"\n",
@@ -271,11 +276,17 @@
271276
},
272277
{
273278
"cell_type": "code",
274-
"execution_count": null,
275-
"metadata": {
276-
"collapsed": false
277-
},
278-
"outputs": [],
279+
"execution_count": 4,
280+
"metadata": {},
281+
"outputs": [
282+
{
283+
"name": "stdout",
284+
"output_type": "stream",
285+
"text": [
286+
"Success: test_compress\n"
287+
]
288+
}
289+
],
279290
"source": [
280291
"%run -i test_compress.py"
281292
]
@@ -297,9 +308,9 @@
297308
"name": "python",
298309
"nbconvert_exporter": "python",
299310
"pygments_lexer": "ipython3",
300-
"version": "3.5.0"
311+
"version": "3.7.2"
301312
}
302313
},
303314
"nbformat": 4,
304-
"nbformat_minor": 0
315+
"nbformat_minor": 1
305316
}
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
from nose.tools import assert_equal
1+
import unittest
22

33

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

66
def test_compress(self, func):
7-
assert_equal(func(None), None)
8-
assert_equal(func(''), '')
9-
assert_equal(func('AABBCC'), 'AABBCC')
10-
assert_equal(func('AAABCCDDDD'), 'A3BCCD4')
11-
assert_equal(func('aaBCCEFFFFKKMMMMMMP taaammanlaarrrr seeeeeeeeek tooo'), 'aaBCCEF4KKM6P ta3mmanlaar4 se9k to3')
7+
self.assertEqual(func(None), None)
8+
self.assertEqual(func(''), '')
9+
self.assertEqual(func('AABBCC'), 'AABBCC')
10+
self.assertEqual(func('AAABCCDDDD'), 'A3BCCD4')
11+
self.assertEqual(
12+
func('aaBCCEFFFFKKMMMMMMP taaammanlaarrrr seeeeeeeeek tooo'),
13+
'aaBCCEF4KKM6P ta3mmanlaar4 se9k to3',
14+
)
1215
print('Success: test_compress')
1316

1417

@@ -18,4 +21,4 @@ def main():
1821

1922

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

0 commit comments

Comments
 (0)