Skip to content

Commit 682aebf

Browse files
updating rendered materials
1 parent 6447403 commit 682aebf

17 files changed

Lines changed: 830 additions & 106 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
test code for the walnut party example
5+
6+
Adapted from the "coding bat" site: https://codingbat.com/python
7+
8+
When squirrels get together for a party, they like to have walnuts.
9+
A squirrel party is successful when the number of walnuts is between
10+
40 and 60, inclusive. Unless it is the weekend, in which case there
11+
is no upper bound on the number of walnuts.
12+
13+
Return True if the party with the given values is successful,
14+
or False otherwise.
15+
"""
16+
17+
18+
# you can change this import to test different versions
19+
from walnut_party import walnut_party
20+
# from walnut_party import walnut_party2 as walnut_party
21+
# from walnut_party import walnut_party3 as walnut_party
22+
23+
24+
def test_1():
25+
assert walnut_party(30, False) is False
26+
27+
28+
def test_2():
29+
assert walnut_party(50, False) is True
30+
31+
32+
def test_3():
33+
assert walnut_party(70, True) is True
34+
35+
36+
def test_4():
37+
assert walnut_party(30, True) is False
38+
39+
40+
def test_5():
41+
assert walnut_party(50, True) is True
42+
43+
44+
def test_6():
45+
assert walnut_party(60, False) is True
46+
47+
48+
def test_7():
49+
assert walnut_party(61, False) is False
50+
51+
52+
def test_8():
53+
assert walnut_party(40, False) is True
54+
55+
56+
def test_9():
57+
assert walnut_party(39, False) is False
58+
59+
60+
def test_10():
61+
assert walnut_party(40, True) is True
62+
63+
64+
def test_11():
65+
assert walnut_party(39, True) is False
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
When squirrels get together for a party, they like to have walnuts.
5+
A squirrel party is successful when the number of walnuts is between
6+
40 and 60, inclusive. Unless it is the weekend, in which case there
7+
is no upper bound on the number of walnuts.
8+
9+
Return True if the party with the given values is successful,
10+
or False otherwise.
11+
"""
12+
13+
14+
def walnut_party(walnuts, is_weekend):
15+
pass

‎_sources/class_schedule/lesson03.rst.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Exercises:
2727
../exercises/slicing.rst
2828
../exercises/list_lab.rst
2929
../exercises/string_formatting.rst
30-
../exercises/mailroom-part1.rst
31-
../exercises/mailroom_tutorial.rst
30+
../exercises/mailroom/mailroom.rst
31+
../exercises/mailroom/mailroom_tutorial.rst
3232

3333
Optional
3434
--------

‎_sources/class_schedule/lesson04.rst.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Exercises:
3838
../exercises/except_exercise.rst
3939
../exercises/unit_testing.rst
4040
../exercises/dict_lab.rst
41-
../exercises/mailroom-part2.rst
41+
../exercises/mailroom/mailroom_with_dicts.rst
4242
../exercises/trigrams/trigrams.rst
4343

4444

‎_sources/class_schedule/lesson05.rst.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ Exercises:
2828
../exercises/exceptions_lab.rst
2929
../exercises/except_exercise.rst
3030
../exercises/comprehensions_lab.rst
31-
../exercises/mailroom-part3.rst
31+
../exercises/mailroom/mailroom_with_exceptions.rst
32+
../exercises/mailroom/mailroom_with_files.rst
33+
3234

‎_sources/class_schedule/lesson06.rst.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Exercises:
3131
:maxdepth: 1
3232

3333
../exercises/args_kwargs_lab.rst
34-
../exercises/mailroom-part4.rst
34+
../exercises/mailroom/mailroom_with_tests.rst
3535

36-
**NOTE:** you will find that most introductions to unit testing with Python use the built in ``unittest`` module. However, it is a bit heavyweight, and requires some knowledge of OOP -- classes, etc. So we'll be using pytest in this class:
36+
**NOTE:** you will find that most introductions to unit testing with Python use the built in ``unittest`` module. However, it is a bit heavyweight, and requires some knowledge of OOP -- classes, etc. So we use pytest in this class:
3737
http://doc.pytest.org/en/latest/. But the principles of testing are the same.

‎_sources/class_schedule/lesson09.rst.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ Exercises:
3939
.. toctree::
4040
:maxdepth: 1
4141

42-
../exercises/mailroom-oo.rst
42+
../exercises/mailroom/mailroom-oo.rst

‎_sources/exercises/unit_testing.rst.txt‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ at the command line:
2525
.. code-block:: bash
2626
2727
$ pytest
28-
============================= test session starts ==============================
29-
platform darwin -- Python 3.7.0, pytest-3.10.1, py-1.5.4, pluggy-0.7.1
30-
rootdir: /Users/Chris/temp/DrMartins, inifile:
31-
plugins: cov-2.6.0
28+
====================== test session starts ======================
29+
platform darwin -- Python 3.8.2, pytest-5.4.3, py-1.8.2, pluggy-0.13.1
30+
rootdir: /Users/chris.barker/Junk/junk
3231
collected 0 items
3332
34-
========================= no tests ran in 0.01 seconds =========================
33+
===================== no tests ran in 0.00s =====================
34+
3535
3636
If you already HAVE some tests -- you may see something different!
3737

3838

3939
Test Driven Development
4040
-----------------------
4141

42-
Download these files, and save them in your own students directory in the class repo:
42+
Download these files, or find them in the exercise repo:
4343

44-
:download:`test_walnut_party.py <../examples/testing/test_walnut_party.py>`
44+
:download:`test_walnut_party.py <unit_testing/test_walnut_party.py>`
4545

4646
and:
4747

48-
:download:`walnut_party.py <../examples/testing/walnut_party.py>`
48+
:download:`walnut_party.py <unit_testing/walnut_party.py>`
4949

5050
(This is the adapted from the codingbat site: http://codingbat.com/prob/p195669)
5151

@@ -59,7 +59,7 @@ You will get a LOT of test failures!
5959

6060
What you've done here is the first step in what is called:
6161

62-
**Test Driven Development**
62+
.. centered:: **Test Driven Development (TDD)**
6363

6464
A bunch of tests exist, but the code to make them pass does not yet exist.
6565

@@ -72,7 +72,7 @@ The tests all failed because currently ``walnut_party()`` looks like:
7272
def walnut_party(walnuts, is_weekend):
7373
pass
7474
75-
A totally do nothing function.
75+
A totally do nothing function -- of course the tests all fail!
7676

7777

7878
Making tests pass

‎class_schedule/index.html‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,55 +127,48 @@
127127
<ul>
128128
<li class="toctree-l1"><a class="reference internal" href="../exercises/string_formatting.html">String Formatting Exercise</a></li>
129129
<li class="toctree-l1"><a class="reference internal" href="../exercises/rot13.html">ROT13</a></li>
130-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom-part1.html">Mailroom Part 1</a></li>
131-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom_tutorial.html">Mailroom Tutorial</a></li>
130+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom.html">Mailroom</a></li>
131+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom_tutorial.html">Mailroom Tutorial</a></li>
132132
</ul>
133133
<ul>
134134
<li class="toctree-l1"><a class="reference internal" href="../modules/Exceptions.html">Exception Handling</a></li>
135135
</ul>
136136
<ul>
137137
<li class="toctree-l1"><a class="reference internal" href="../exercises/exceptions_lab.html">Exceptions Lab</a></li>
138138
<li class="toctree-l1"><a class="reference internal" href="../exercises/except_exercise.html">Exceptions Exercise</a></li>
139+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom_with_exceptions.html">Mailroom With Exceptions</a></li>
139140
</ul>
140141
<ul>
141142
<li class="toctree-l1"><a class="reference internal" href="../modules/Testing.html">Testing</a></li>
142143
<li class="toctree-l1"><a class="reference internal" href="../modules/TestDrivenDevelopment.html">Test Driven Development</a></li>
143144
</ul>
144145
<ul>
145146
<li class="toctree-l1"><a class="reference internal" href="../exercises/unit_testing.html">Introduction To Unit Testing</a></li>
146-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom-part4.html">Mailroom Part 4</a></li>
147+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom_with_tests.html">Mailroom With Unit Tests</a></li>
147148
</ul>
148149
<ul>
149150
<li class="toctree-l1"><a class="reference internal" href="../modules/DictsAndSets.html">Dictionaries and Sets</a></li>
150151
<li class="toctree-l1"><a class="reference internal" href="../modules/DictionaryAsSwitch.html">Using a Dictionary to <code class="docutils literal notranslate"><span class="pre">switch</span></code></a></li>
151152
</ul>
152153
<ul>
153154
<li class="toctree-l1"><a class="reference internal" href="../exercises/dict_lab.html">Dictionary and Set Lab</a></li>
154-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom-part2.html">Mailroom Part 2</a></li>
155+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom_with_dicts.html">Mailroom With Dicts</a></li>
155156
</ul>
156157
<ul>
157158
<li class="toctree-l1"><a class="reference internal" href="../modules/Files.html">File Reading and Writing</a></li>
158159
</ul>
159160
<ul>
160161
<li class="toctree-l1"><a class="reference internal" href="../exercises/file_lab.html">File Exercise</a></li>
161-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom-part2.html">Mailroom Part 2</a></li>
162+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom_with_files.html">Mailroom With Files</a></li>
162163
<li class="toctree-l1"><a class="reference internal" href="../exercises/trigrams/trigrams.html">Trigrams – Simple Text Manipulation</a></li>
163164
</ul>
164165
<ul>
165-
<li class="toctree-l1"><a class="reference internal" href="../modules/NamingThings.html">Style and Naming</a></li>
166-
<li class="toctree-l1"><a class="reference internal" href="../modules/Modules.html">Code Structure, Modules, and Namespaces</a></li>
167-
<li class="toctree-l1"><a class="reference internal" href="../modules/Documentation.html">Documentation</a></li>
168-
<li class="toctree-l1"><a class="reference internal" href="../modules/Packaging.html">Packages and Packaging</a></li>
169-
</ul>
170-
<ul>
171-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom-pkg.html">Mailroom – as a Python Package</a></li>
172-
</ul>
173-
<ul>
174166
<li class="toctree-l1"><a class="reference internal" href="../modules/Comprehensions.html">Comprehensions</a></li>
175167
<li class="toctree-l1"><a class="reference internal" href="../modules/CollectionsModule.html">The Collections Module</a></li>
176168
</ul>
177169
<ul>
178170
<li class="toctree-l1"><a class="reference internal" href="../exercises/comprehensions_lab.html">Comprehensions Lab</a></li>
171+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom_with_comprehensions.html">Mailroom With Comprehensions</a></li>
179172
</ul>
180173
<ul>
181174
<li class="toctree-l1"><a class="reference internal" href="../modules/AdvancedArgumentPassing.html">Advanced Argument Passing</a></li>
@@ -187,7 +180,16 @@
187180
</ul>
188181
<ul>
189182
<li class="toctree-l1"><a class="reference internal" href="../exercises/oo_intro.html">OO Intro - Report Class</a></li>
190-
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom-oo.html">Mailroom - Object Oriented</a></li>
183+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom-oo.html">Mailroom - Object Oriented</a></li>
184+
</ul>
185+
<ul>
186+
<li class="toctree-l1"><a class="reference internal" href="../modules/NamingThings.html">Style and Naming</a></li>
187+
<li class="toctree-l1"><a class="reference internal" href="../modules/Modules.html">Code Structure, Modules, and Namespaces</a></li>
188+
<li class="toctree-l1"><a class="reference internal" href="../modules/Documentation.html">Documentation</a></li>
189+
<li class="toctree-l1"><a class="reference internal" href="../modules/Packaging.html">Packages and Packaging</a></li>
190+
</ul>
191+
<ul>
192+
<li class="toctree-l1"><a class="reference internal" href="../exercises/mailroom/mailroom-pkg.html">Mailroom – as a Python Package</a></li>
191193
</ul>
192194
<ul>
193195
<li class="toctree-l1"><a class="reference internal" href="../modules/Properties.html">Properties</a></li>
@@ -214,7 +216,7 @@
214216
<li class="toctree-l1"><a class="reference internal" href="../modules/IPythonParallel.html">IPython Parallel Quickstart</a></li>
215217
</ul>
216218
<ul>
217-
<li class="toctree-l1"><a class="reference internal" href="../modules/Testing_advanced.html">Testing</a></li>
219+
<li class="toctree-l1"><a class="reference internal" href="../modules/Testing_advanced.html">Advanced Testing</a></li>
218220
</ul>
219221
<ul>
220222
<li class="toctree-l1"><a class="reference internal" href="../modules/Pep8.html">Coding Style and Linting</a></li>

0 commit comments

Comments
 (0)