[py-svn] r63168 - py/extradoc/talk/pycon-us-2009/pytest-introduction
briandorsey at codespeak.net
briandorsey at codespeak.net
Sat Mar 21 09:06:20 CET 2009
Author: briandorsey
Date: Sat Mar 21 09:06:18 2009
New Revision: 63168
Modified:
py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.html
py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.txt
Log:
added slides for the 'branching out' section
Modified: py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.html
==============================================================================
--- py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.html (original)
+++ py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.html Sat Mar 21 09:06:18 2009
@@ -622,10 +622,11 @@
<li>--nocapture - disable catching of sys.stdout/stderr output.</li>
<li>--exitfirst (*) - exit instantly on first error or failed test.</li>
<li>--showlocals (*) - show locals in tracebacks.</li>
+<li>--pdb (*) - start pdb (the Python debugger) on errors.</li>
<li>--looponfailing (*) - loop on failing test set.</li>
<li>-k (*) - only run test items matching the given keyword.</li>
<li>--exec (*) - python executable to run the tests with.</li>
-<li>--tb/fulltrace - different options to control traceback generation</li>
+<li>--tb/fulltrace - different options to control traceback generation.</li>
</ul>
<p>(*) more detail in advanced tutorial</p>
</div>
@@ -645,21 +646,22 @@
<h1>demo: -k</h1>
<p>TODO: write demo script</p>
</div>
-<div class="slide" id="exercise-4-20-min">
-<h1>exercise 4 (~20 min)</h1>
+<div class="slide" id="exercise-4-10-min">
+<h1>exercise 4 (~10 min)</h1>
<ul class="simple">
<li>--nocapture - disable catching of sys.stdout/stderr output.</li>
<li>--exitfirst (*) - exit instantly on first error or failed test.</li>
<li>--showlocals (*) - show locals in tracebacks.</li>
+<li>--pdb (*) - start pdb (the Python debugger) on errors.</li>
<li>--looponfailing (*) - loop on failing test set.</li>
<li>-k (*) - only run test items matching the given keyword.</li>
<li>--exec (*) - python executable to run the tests with.</li>
-<li>--tb/fulltrace - different options to control traceback generation</li>
+<li>--tb/fulltrace - different options to control traceback generation.</li>
</ul>
<p class="handout">Experiment with a few of these options, ask questions and play.</p>
<p class="handout">If you're in the advanced class this afternoon. Think about other options
you'd like. Maybe we can make a plugin.</p>
-<p class="handout">TODO: check with holger - time to make a plugin?</p>
+<p class="handout">TODO: check with holger - time to make a plugin in the advanced class?</p>
</div>
<div class="slide" id="branching-out">
<h1>branching out</h1>
@@ -667,10 +669,40 @@
<ul class="simple">
<li>skipping tests</li>
<li>generative tests</li>
-<li>--pdb</li>
<li>10 minute work time - exercises</li>
</ul>
-<p>TODO: split</p>
+</div>
+<div class="slide" id="skipping-tests">
+<h1>skipping tests</h1>
+<pre class="literal-block">
+import py
+
+def test_something_we_want_to_skip():
+ some_code()
+ py.test.skip("need to decide what it should do.")
+ more_code()
+ assert something == True
+</pre>
+</div>
+<div class="slide" id="generative-tests">
+<h1>generative tests</h1>
+<pre class="literal-block">
+def contains_spam(item):
+ assert 'spam' in item.lower()
+
+def test_ensure_sufficient_spam():
+ data = ['spam', 'SPAM', 'eggs & spam',
+ 'fish','spammy', 'more spam']
+ for item in data:
+ yeild contains_spam, item
+</pre>
+</div>
+<div class="slide" id="exercise-5-10-min">
+<h1>exercise 5 (~10 min)</h1>
+<ul class="simple">
+<li>skipping tests</li>
+<li>generative tests</li>
+</ul>
</div>
<div class="slide" id="using-doctests">
<h1>using doctests</h1>
Modified: py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.txt
==============================================================================
--- py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.txt (original)
+++ py/extradoc/talk/pycon-us-2009/pytest-introduction/pytest-introduction.txt Sat Mar 21 09:06:18 2009
@@ -266,9 +266,6 @@
print "debug text" | py.test.raises(
assert False | ValueError, int, 'foo')
- def test_bonus():
- py.test.raises(ValueError, int, 'foo')
-
TODO: write handout/exercise
@@ -364,6 +361,7 @@
- --nocapture - disable catching of sys.stdout/stderr output.
- --exitfirst (*) - exit instantly on first error or failed test.
- --showlocals (*) - show locals in tracebacks.
+- --pdb (*) - start pdb (the Python debugger) on errors.
- --looponfailing (*) - loop on failing test set.
- -k (*) - only run test items matching the given keyword.
- --exec (*) - python executable to run the tests with.
@@ -401,6 +399,7 @@
- --nocapture - disable catching of sys.stdout/stderr output.
- --exitfirst (*) - exit instantly on first error or failed test.
- --showlocals (*) - show locals in tracebacks.
+- --pdb (*) - start pdb (the Python debugger) on errors.
- --looponfailing (*) - loop on failing test set.
- -k (*) - only run test items matching the given keyword.
- --exec (*) - python executable to run the tests with.
@@ -413,7 +412,7 @@
If you're in the advanced class this afternoon. Think about other options
you'd like. Maybe we can make a plugin.
- TODO: check with holger - time to make a plugin?
+ TODO: check with holger - time to make a plugin in the advanced class?
branching out
@@ -423,10 +422,69 @@
- skipping tests
- generative tests
-- --pdb
- 10 minute work time - exercises
-TODO: split
+
+skipping tests
+==============
+
+::
+
+ import py
+
+ def test_something_we_want_to_skip():
+ some_code()
+ py.test.skip("need to decide what it should do.")
+ more_code()
+ assert something == True
+
+
+generative tests 1
+==================
+
+::
+
+ def test_ensure_sufficient_spam():
+ assert 'spam' in 'spam'.lower()
+ assert 'spam' in 'SPAM'.lower()
+ assert 'spam' in 'eggs & spam'.lower()
+ assert 'spam' in 'fish'.lower()
+ assert 'spam' in 'spammy'.lower()
+ assert 'spam' in 'more spam'.lower()
+
+
+generative tests 2
+==================
+
+::
+
+ def test_ensure_sufficient_spam():
+ data = ['spam', 'SPAM', 'eggs & spam',
+ 'fish','spammy', 'more spam']
+ for item in data:
+ assert 'spam' in item.lower()
+
+
+generative tests 3
+==================
+
+::
+
+ def contains_spam(item):
+ assert 'spam' in item.lower()
+
+ def test_ensure_sufficient_spam():
+ data = ['spam', 'SPAM', 'eggs & spam',
+ 'fish','spammy', 'more spam']
+ for item in data:
+ yeild contains_spam, item
+
+
+exercise 5 (~10 min)
+=====================
+
+- skipping tests
+- generative tests
using doctests
More information about the pytest-commit
mailing list