Skip to content

Commit 4ba5c96

Browse files
committed
Merge pull request #1 from gvwilson/gh-pages
Merging latest version of template
2 parents 4f7114a + 9d28369 commit 4ba5c96

40 files changed

+332
-375
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
README.html
2+
LAYOUT.html
3+
FAQ.html
4+
DESIGN.html
5+
CONTRIBUTING.html
6+
CONDUCT.html
7+
*~
8+
*.pyc
9+
_site
10+
.DS_Store

.mailmap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
4+
Francois Michonneau <[email protected]> <[email protected]>
5+

.nojekyll

Whitespace-only changes.

.update-copyright.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[project]
2+
vcs: Git
3+
4+
[files]
5+
authors: yes
6+
files: no

01-basics.html

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<article>
2727
<div class="row">
2828
<div class="col-md-10 col-md-offset-1">
29-
<h1 class="title">Testing</h1>
30-
<h2 class="subtitle">Basics of testing</h2>
31-
<section class="objectives panel panel-warning">
29+
<a href="index.html"><h1 class="title">Testing</h1></a>
30+
<h2 class="subtitle">Basics of Testing</h2>
31+
<section class="objectives panel panel-warning">
3232
<div class="panel-heading">
3333
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
3434
</div>
@@ -46,8 +46,11 @@ <h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2
4646
<li>The act of writing tests can help clarify how the software should be perform when you are done.</li>
4747
<li>In fact, starting to write the tests <em>before</em> you even write the software might be advisable. (Such a practice is called <em>test-driven development</em>, which we will discuss in greater detail <a href="09-tdd.html">later in the lesson</a>.)</li>
4848
</ul>
49-
<blockquote>
50-
<h3>What Kinds of Tests Exist</h3>
49+
<aside class="callout panel panel-info">
50+
<div class="panel-heading">
51+
<h2><span class="glyphicon glyphicon-pushpin"></span>What Kinds of Tests Exist</h2>
52+
</div>
53+
<div class="panel-body">
5154
<p>There are many ways to test software, such as:</p>
5255
<ul>
5356
<li>Assertions</li>
@@ -56,28 +59,18 @@ <h3>What Kinds of Tests Exist</h3>
5659
<li>Regresson Tests</li>
5760
<li>Integration Tests</li>
5861
</ul>
59-
</blockquote>
62+
</div>
63+
</aside>
6064
<p><em>Exceptions and Assertions</em>: While writing code, <code>exceptions</code> and <code>assertions</code> can be added to sound an alarm as runtime problems come up. These kinds of tests, are embedded in the software iteself and handle, as their name implies, exceptional cases rather than the norm.</p>
6165
<p><em>Unit Tests</em>: Unit tests investigate the behavior of units of code (such as functions, classes, or data structures). By validating each software unit across the valid range of its input and output parameters, tracking down unexpected behavior that may appear when the units are combined is made vastly simpler.</p>
6266
<p><em>Regression Tests</em>: Regression tests defend against new bugs, or regressions, which might appear due to new software and updates.</p>
6367
<p><em>Integration Tests</em>: Integration tests check that various pieces of the software work together as expected.</p>
64-
<blockquote>
65-
<h2>Key Points</h2>
66-
<ul>
67-
<li>Tests compare that the result observed from running code is the same as what was expected ahead of time.</li>
68-
<li>Tests should be written at the same time as the code they are testing is written.</li>
69-
<li>Assertions and exceptions are like alarm systems embedded in the software, guarding against exceptional bahavior.</li>
70-
<li>Unit tests try to test the smallest pieces of code possible, usually functions and methods.</li>
71-
<li>Integration tests make sure that code units work together properly.</li>
72-
<li>Regression tests ensure that everything works the same today as it did yesterday.</li>
73-
</ul>
74-
</blockquote>
7568
</div>
7669
</div>
7770
</article>
7871
<div class="footer">
7972
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
80-
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/git-novice">Source</a>
73+
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
8174
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
8275
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
8376
</div>

01-basics.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: page
33
title: Testing
4-
subtitle: Basics of testing
4+
subtitle: Basics of Testing
55
minutes: 5
66
---
77
> ## Learning Objectives {.objectives}
@@ -24,7 +24,8 @@ This is analogous to experiment design in the experimental science world:
2424
might be advisable. (Such a practice is called _test-driven development_,
2525
which we will discuss in greater detail [later in the lesson](09-tdd.html).)
2626

27-
> ### What Kinds of Tests Exist
27+
> ## What Kinds of Tests Exist {.callout}
28+
>
2829
> There are many ways to test software, such as:
2930
>
3031
> - Assertions
@@ -49,14 +50,3 @@ which might appear due to new software and updates.
4950

5051
*Integration Tests*: Integration tests check that various pieces of the
5152
software work together as expected.
52-
53-
54-
> ## Key Points {.keypoints}
55-
>
56-
> - Tests compare that the result observed from running code is the same as what was expected ahead of time.
57-
> - Tests should be written at the same time as the code they are testing is written.
58-
> - Assertions and exceptions are like alarm systems embedded in the software, guarding against exceptional bahavior.
59-
> - Unit tests try to test the smallest pieces of code possible, usually functions and methods.
60-
> - Integration tests make sure that code units work together properly.
61-
> - Regression tests ensure that everything works the same today as it did yesterday.
62-

02-assertions.html

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<article>
2727
<div class="row">
2828
<div class="col-md-10 col-md-offset-1">
29-
<h1 class="title">Testing</h1>
29+
<a href="index.html"><h1 class="title">Testing</h1></a>
3030
<h2 class="subtitle">Assertions</h2>
31-
<section class="objectives panel panel-warning">
31+
<section class="objectives panel panel-warning">
3232
<div class="panel-heading">
3333
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
3434
</div>
@@ -55,7 +55,7 @@ <h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2
5555
<p>Also, input checking may require decending a rabbit hole of exceptional cases. What happens when the input provided to the mean function is a string, rather than a list of numbers?</p>
5656
<section class="challenge panel panel-success">
5757
<div class="panel-heading">
58-
<h2><span class="glyphicon glyphicon-pencil"></span>Challenge Insert an Assertion</h2>
58+
<h2><span class="glyphicon glyphicon-pencil"></span>Insert an Assertion</h2>
5959
</div>
6060
<div class="panel-body">
6161
<ol style="list-style-type: decimal">
@@ -73,7 +73,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Challenge Insert an Assertio
7373
<p>Assertions are also helpful for catching abnormal behaviors, such as those that arise with floating point arithmetic.</p>
7474
<section class="challenge panel panel-success">
7575
<div class="panel-heading">
76-
<h2><span class="glyphicon glyphicon-pencil"></span>Challenge: Almost Equal</h2>
76+
<h2><span class="glyphicon glyphicon-pencil"></span>Almost Equal</h2>
7777
</div>
7878
<div class="panel-body">
7979
<p>Assertions are also helpful for catching abnormal behaviors, such as those that arise with floating point arithmetic. Using the assert keyword, how could you test whether some value is almost the same as another value?</p>
@@ -90,30 +90,19 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Challenge: Almost Equal</h2>
9090
</div>
9191
</section>
9292
<p>To help with situations such as those above, there are classes of more helpful assertions that we will use often in later parts of this testing lesson as the building blocks of our tests. The nose testing package contains many of them.</p>
93-
<h3 id="nose">Nose</h3>
93+
<h2 id="nose">Nose</h2>
9494
<p>The nose testing framework has built-in assertion types implementing <code>assert_almost_equal</code>, <code>assert_true</code>, <code>assert_false</code>, <code>assert_raises</code>, <code>assert_is_instance</code>, and others.</p>
9595
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">from</span> nose.tools <span class="ch">import</span> assert_almost_equal
9696
<span class="ch">from</span> mynum <span class="ch">import</span> a
9797
assert_almost_equal(a, <span class="dv">2</span>, places=<span class="dv">2</span>)
9898
assert_almost_equal(a, <span class="dv">2</span>, delta=<span class="fl">0.003</span>)</code></pre>
9999
<p>These assertions give much more helpful error messages and have much more powerful features than the simple assert keyword. An even more powerful sibling of the assertion is the <em>exception</em>. We’ll learn about those in the next lesson.</p>
100-
<blockquote>
101-
<h2>Key Points</h2>
102-
<ul>
103-
<li>Assertions are one line tests embedded in code.</li>
104-
<li>The <code>assert</code> keyword is used to set an assertion.</li>
105-
<li>Assertions halt execution if the argument is false.</li>
106-
<li>Assertions do nothing if the argument is true.</li>
107-
<li>The <code>nose.tools</code> package provides more informative assertions.</li>
108-
<li>Assertions are the building blocks of tests.</li>
109-
</ul>
110-
</blockquote>
111100
</div>
112101
</div>
113102
</article>
114103
<div class="footer">
115104
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
116-
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/git-novice">Source</a>
105+
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
117106
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
118107
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
119108
</div>

02-assertions.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ Also, input checking may require decending a rabbit hole of exceptional cases.
4848
What happens when the input provided to the mean function is a string, rather
4949
than a list of numbers?
5050

51-
52-
> ## Challenge Insert an Assertion {.challenge}
53-
>
51+
> ## Insert an Assertion {.challenge}
5452
>
5553
> 1. Open an IPython Notebook
5654
> 2. Create the following function:
@@ -70,7 +68,8 @@ than a list of numbers?
7068
Assertions are also helpful for catching abnormal behaviors, such as those that
7169
arise with floating point arithmetic.
7270
73-
> ## Challenge: Almost Equal {.challenge}
71+
> ## Almost Equal {.challenge}
72+
>
7473
> Assertions are also helpful for catching abnormal behaviors, such as those
7574
> that arise with floating point arithmetic. Using the assert keyword, how could
7675
> you test whether some value is almost the same as another value?
@@ -91,7 +90,7 @@ To help with situations such as those above, there are classes of more helpful
9190
assertions that we will use often in later parts of this testing lesson as the
9291
building blocks of our tests. The nose testing package contains many of them.
9392
94-
### Nose
93+
## Nose
9594
9695
The nose testing framework has built-in assertion types implementing
9796
`assert_almost_equal`, `assert_true`, `assert_false`, `assert_raises`,
@@ -108,13 +107,3 @@ These assertions give much more helpful error messages and have much more
108107
powerful features than the simple assert keyword. An even more powerful sibling
109108
of the assertion is the _exception_. We'll learn about those in the next
110109
lesson.
111-
112-
113-
> ## Key Points {.keypoints}
114-
>
115-
> - Assertions are one line tests embedded in code.
116-
> - The `assert` keyword is used to set an assertion.
117-
> - Assertions halt execution if the argument is false.
118-
> - Assertions do nothing if the argument is true.
119-
> - The `nose.tools` package provides more informative assertions.
120-
> - Assertions are the building blocks of tests.

03-exceptions.html

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<article>
2727
<div class="row">
2828
<div class="col-md-10 col-md-offset-1">
29-
<h1 class="title">Testing</h1>
29+
<a href="index.html"><h1 class="title">Testing</h1></a>
3030
<h2 class="subtitle">Exceptions</h2>
31-
<section class="objectives panel panel-warning">
31+
<section class="objectives panel panel-warning">
3232
<div class="panel-heading">
3333
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
3434
</div>
@@ -71,7 +71,7 @@ <h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2
7171
<span class="kw">raise</span> <span class="ot">TypeError</span>(detail.<span class="ot">__str__</span>() + <span class="st">&quot;</span><span class="ch">\n</span><span class="st">&quot;</span> + msg)</code></pre>
7272
<section class="challenge panel panel-success">
7373
<div class="panel-heading">
74-
<h2><span class="glyphicon glyphicon-pencil"></span>Challenge: What Else Can Go Wrong?</h2>
74+
<h2><span class="glyphicon glyphicon-pencil"></span>What Else Can Go Wrong?</h2>
7575
</div>
7676
<div class="panel-body">
7777
<ol style="list-style-type: decimal">
@@ -82,7 +82,7 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Challenge: What Else Can Go
8282
</section>
8383
<section class="challenge panel panel-success">
8484
<div class="panel-heading">
85-
<h2><span class="glyphicon glyphicon-pencil"></span>Challenge: Cause all of the errors</h2>
85+
<h2><span class="glyphicon glyphicon-pencil"></span>Cause All of the Errors</h2>
8686
</div>
8787
<div class="panel-body">
8888
<ul>
@@ -91,20 +91,12 @@ <h2><span class="glyphicon glyphicon-pencil"></span>Challenge: Cause all of the
9191
</div>
9292
</section>
9393
<p>Exceptions have the advantage of being simple to include and powerfully helpful to the user. However, not all behaviors can or should be found with runtime exceptions. Most behaviors should be validated with unit tests.</p>
94-
<blockquote>
95-
<h2>Key Points</h2>
96-
<ul>
97-
<li>Exceptions are effectively specialized runtime tests</li>
98-
<li>Exceptions can be caught and handled with a try-except block</li>
99-
<li>Many built-in Exception types are available</li>
100-
</ul>
101-
</blockquote>
10294
</div>
10395
</div>
10496
</article>
10597
<div class="footer">
10698
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
107-
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/git-novice">Source</a>
99+
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
108100
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
109101
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
110102
</div>

03-exceptions.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,17 @@ def mean(num_list):
7171
raise TypeError(detail.__str__() + "\n" + msg)
7272
~~~
7373

74-
> ## Challenge: What Else Can Go Wrong? {.challenge}
74+
> ## What Else Can Go Wrong? {.challenge}
75+
>
7576
> 1. Think of some other type of exception that could be raised by the try
7677
> block.
7778
> 2. Guard against it by adding an except clause.
7879
79-
> ## Challenge: Cause all of the errors {.challenge}
80+
> ## Cause All of the Errors {.challenge}
8081
>
8182
> - Use the mean function in three different ways, so that you cause each
8283
> exceptional case.
8384
8485
Exceptions have the advantage of being simple to include and powerfully helpful
8586
to the user. However, not all behaviors can or should be found with runtime
8687
exceptions. Most behaviors should be validated with unit tests.
87-
88-
> ## Key Points {.keypoints}
89-
>
90-
> - Exceptions are effectively specialized runtime tests
91-
> - Exceptions can be caught and handled with a try-except block
92-
> - Many built-in Exception types are available
93-

0 commit comments

Comments
 (0)