Skip to content

Commit c511ed5

Browse files
author
Yihan Cao
committed
Update 07_test.ipynb
try out the example
1 parent bfcf100 commit c511ed5

File tree

1 file changed

+61
-54
lines changed

1 file changed

+61
-54
lines changed

chapter02_best_practices/07_test.ipynb

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"name": "stdout",
1717
"output_type": "stream",
1818
"text": [
19-
"Overwriting first.py\n"
19+
"Writing first.py\n"
2020
]
2121
}
2222
],
@@ -42,7 +42,6 @@
4242
"source": [
4343
"%%writefile -a first.py\n",
4444
"\n",
45-
"\n",
4645
"# This is appended to the file.\n",
4746
"def test_first():\n",
4847
" assert first([1, 2, 3]) == 1"
@@ -57,12 +56,12 @@
5756
"name": "stdout",
5857
"output_type": "stream",
5958
"text": [
60-
"def first(l):\n",
61-
" return l[0]\n",
62-
"\n",
63-
"# This is appended to the file.\n",
64-
"def test_first():\n",
65-
" assert first([1, 2, 3]) == 1\n"
59+
"def first(l):\r\n",
60+
" return l[0]\r\n",
61+
"\r\n",
62+
"# This is appended to the file.\r\n",
63+
"def test_first():\r\n",
64+
" assert first([1, 2, 3]) == 1\r\n"
6665
]
6766
}
6867
],
@@ -79,18 +78,15 @@
7978
"name": "stdout",
8079
"output_type": "stream",
8180
"text": [
82-
"============= test session starts ==============\n",
83-
"platform linux -- Python 3.6.3, pytest-3.2.1, py-1.4.34\n",
84-
"rootdir: ~/git/cookbook-2nd/chapter02_best_practices:\n",
85-
"plugins: cov-2.5.1\n",
86-
"\n",
87-
"collecting 0 items\n",
88-
"collecting 1 item\n",
89-
"collected 1 item\n",
90-
"\n",
91-
"first.py .\n",
92-
"\n",
93-
"=========== 1 passed in 0.00 seconds ===========\n"
81+
"\u001b[1m============================= test session starts ==============================\u001b[0m\r\n",
82+
"platform darwin -- Python 3.8.0, pytest-5.3.5, py-1.8.1, pluggy-0.13.1\r\n",
83+
"rootdir: /Users/yihanc/repositories/personal/cookbook-2nd-code/chapter02_best_practices\r\n",
84+
"\u001b[1mcollecting ... \u001b[0m\u001b[1m\r",
85+
"collected 1 item \u001b[0m\r\n",
86+
"\r\n",
87+
"first.py \u001b[32m.\u001b[0m\u001b[32m [100%]\u001b[0m\r\n",
88+
"\r\n",
89+
"\u001b[32m============================== \u001b[32m\u001b[1m1 passed\u001b[0m\u001b[32m in 0.01s\u001b[0m\u001b[32m ===============================\u001b[0m\r\n"
9490
]
9591
}
9692
],
@@ -130,35 +126,31 @@
130126
"name": "stdout",
131127
"output_type": "stream",
132128
"text": [
133-
"============= test session starts ==============\n",
134-
"platform linux -- Python 3.6.3, pytest-3.2.1, py-1.4.34\n",
135-
"rootdir: ~/git/cookbook-2nd/chapter02_best_practices:\n",
136-
"plugins: cov-2.5.1\n",
129+
"\u001b[1m============================= test session starts ==============================\u001b[0m\n",
130+
"platform darwin -- Python 3.8.0, pytest-5.3.5, py-1.8.1, pluggy-0.13.1\n",
131+
"rootdir: /Users/yihanc/repositories/personal/cookbook-2nd-code/chapter02_best_practices\n",
132+
"collected 1 item \u001b[0m\n",
137133
"\n",
138-
"collecting 0 items\n",
139-
"collecting 1 item\n",
140-
"collected 1 item\n",
134+
"first.py \u001b[31mF\u001b[0m\u001b[31m [100%]\u001b[0m\n",
141135
"\n",
142-
"first.py F\n",
136+
"=================================== FAILURES ===================================\n",
137+
"\u001b[31m\u001b[1m__________________________________ test_first __________________________________\u001b[0m\n",
143138
"\n",
144-
"=================== FAILURES ===================\n",
145-
"__________________ test_first __________________\n",
139+
"\u001b[1m def test_first():\u001b[0m\n",
140+
"\u001b[1m assert first([1, 2, 3]) == 1\u001b[0m\n",
141+
"\u001b[1m> assert first([]) is None\u001b[0m\n",
146142
"\n",
147-
" def test_first():\n",
148-
" assert first([1, 2, 3]) == 1\n",
149-
"> assert first([]) is None\n",
150-
"\n",
151-
"first.py:6:\n",
152-
" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n",
143+
"\u001b[1m\u001b[31mfirst.py\u001b[0m:6: \n",
144+
"_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n",
153145
"\n",
154146
"l = []\n",
155147
"\n",
156-
" def first(l):\n",
157-
"> return l[0]\n",
158-
"E IndexError: list index out of range\n",
148+
"\u001b[1m def first(l):\u001b[0m\n",
149+
"\u001b[1m> return l[0]\u001b[0m\n",
150+
"\u001b[1m\u001b[31mE IndexError: list index out of range\u001b[0m\n",
159151
"\n",
160-
"first.py:2: IndexError\n",
161-
"=========== 1 failed in 0.02 seconds ===========\n"
152+
"\u001b[1m\u001b[31mfirst.py\u001b[0m:2: IndexError\n",
153+
"\u001b[31m============================== \u001b[31m\u001b[1m1 failed\u001b[0m\u001b[31m in 0.05s\u001b[0m\u001b[31m ===============================\u001b[0m\n"
162154
]
163155
}
164156
],
@@ -198,18 +190,15 @@
198190
"name": "stdout",
199191
"output_type": "stream",
200192
"text": [
201-
"============= test session starts ==============\n",
202-
"platform linux -- Python 3.6.3, pytest-3.2.1, py-1.4.34\n",
203-
"rootdir: ~/git/cookbook-2nd/chapter02_best_practices:\n",
204-
"plugins: cov-2.5.1\n",
205-
"\n",
206-
"collecting 0 items\n",
207-
"collecting 1 item\n",
208-
"collected 1 item\n",
209-
"\n",
210-
"first.py .\n",
211-
"\n",
212-
"=========== 1 passed in 0.00 seconds ===========\n"
193+
"\u001b[1m============================= test session starts ==============================\u001b[0m\r\n",
194+
"platform darwin -- Python 3.8.0, pytest-5.3.5, py-1.8.1, pluggy-0.13.1\r\n",
195+
"rootdir: /Users/yihanc/repositories/personal/cookbook-2nd-code/chapter02_best_practices\r\n",
196+
"\u001b[1mcollecting ... \u001b[0m\u001b[1m\r",
197+
"collected 1 item \u001b[0m\r\n",
198+
"\r\n",
199+
"first.py \u001b[32m.\u001b[0m\u001b[32m [100%]\u001b[0m\r\n",
200+
"\r\n",
201+
"\u001b[32m============================== \u001b[32m\u001b[1m1 passed\u001b[0m\u001b[32m in 0.01s\u001b[0m\u001b[32m ===============================\u001b[0m\r\n"
213202
]
214203
}
215204
],
@@ -218,7 +207,25 @@
218207
]
219208
}
220209
],
221-
"metadata": {},
210+
"metadata": {
211+
"kernelspec": {
212+
"display_name": "Python 3",
213+
"language": "python",
214+
"name": "python3"
215+
},
216+
"language_info": {
217+
"codemirror_mode": {
218+
"name": "ipython",
219+
"version": 3
220+
},
221+
"file_extension": ".py",
222+
"mimetype": "text/x-python",
223+
"name": "python",
224+
"nbconvert_exporter": "python",
225+
"pygments_lexer": "ipython3",
226+
"version": "3.7.4"
227+
}
228+
},
222229
"nbformat": 4,
223230
"nbformat_minor": 2
224231
}

0 commit comments

Comments
 (0)