[py-svn] r63333 - py/extradoc/talk/pycon-us-2009/pytest-introduction
briandorsey at codespeak.net
briandorsey at codespeak.net
Thu Mar 26 04:34:53 CET 2009
Author: briandorsey
Date: Thu Mar 26 04:34:52 2009
New Revision: 63333
Added:
py/extradoc/talk/pycon-us-2009/pytest-introduction/test_doctest_example.txt
py/extradoc/talk/pycon-us-2009/pytest-introduction/test_examples.py
py/extradoc/talk/pycon-us-2009/pytest-introduction/test_hello.py
py/extradoc/talk/pycon-us-2009/pytest-introduction/test_trace_setup.py
Removed:
py/extradoc/talk/pycon-us-2009/pytest-introduction/test_examples_auto.py
Log:
Added various example files.
Added: py/extradoc/talk/pycon-us-2009/pytest-introduction/test_doctest_example.txt
==============================================================================
--- (empty file)
+++ py/extradoc/talk/pycon-us-2009/pytest-introduction/test_doctest_example.txt Thu Mar 26 04:34:52 2009
@@ -0,0 +1,2 @@
+>>> import os
+>>> os.pathsep
Added: py/extradoc/talk/pycon-us-2009/pytest-introduction/test_examples.py
==============================================================================
--- (empty file)
+++ py/extradoc/talk/pycon-us-2009/pytest-introduction/test_examples.py Thu Mar 26 04:34:52 2009
@@ -0,0 +1,103 @@
+# function or class
+#
+
+def test_something():
+ assert True
+
+class TestSomething():
+ def test_something(self):
+ assert True
+# automatic test discovery
+#
+
+def test_something():
+ assert True
+
+class TestSomething():
+ def test_something(self):
+ assert True
+
+# search all test_* and *_test files
+# assert introspection
+#
+
+def test_assert_introspection():
+ assert True # assertTrue()
+ assert 1 == 1 # assertEqual()
+ assert not 1 == 2 # assertNotEqual()
+ assert not False # assertFalse()
+# print() debugging
+#
+
+import py
+
+def test_something1():
+ print "Useful debugging information."
+ assert True
+
+ at py.test.mark(xfail="Expected failure.")
+def test_something2():
+ print "Useful debugging information."
+ assert False
+# exercise 2 (~10 min)
+#
+
+def test_one():
+ print "debug text"
+ assert True
+def test_two():
+ assert 1 == 1
+ at py.test.mark(xfail="Expected failure.")
+def test_three():
+ assert 1 == 2
+def test_bonus():
+ py.test.raises(ValueError, int, 'foo')
+# exercise 3 (~10 min)
+#
+
+class TestSomething():
+ def setup_class(cls):
+ pass
+ def setup_method(self, method):
+ pass
+
+ def test_one(self):
+ assert True
+ def test_two(self):
+ assert 1 == 1
+# skipping tests
+#
+
+import py
+
+def test_something_we_want_to_skip():
+ py.test.skip("fix delayed.")
+ assert True
+# generative tests 1
+#
+
+def test_ensure_sufficient_spam1():
+ assert 'spam' in 'spam'.lower()
+ assert 'spam' in 'SPAM'.lower()
+ assert 'spam' in 'eggs & spam'.lower()
+ assert 'spam' in 'spammy'.lower()
+ assert 'spam' in 'more spam'.lower()
+# generative tests 2
+#
+
+def test_ensure_sufficient_spam2():
+ data = ['spam', 'SPAM', 'eggs & spam',
+ '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_spam3():
+ data = ['spam', 'SPAM', 'eggs & spam',
+ 'spammy', 'more spam']
+ for item in data:
+ yield contains_spam, item
Deleted: /py/extradoc/talk/pycon-us-2009/pytest-introduction/test_examples_auto.py
==============================================================================
--- /py/extradoc/talk/pycon-us-2009/pytest-introduction/test_examples_auto.py Thu Mar 26 04:34:52 2009
+++ (empty file)
@@ -1,112 +0,0 @@
-# function or class
-#
-
-def test_something():
- assert True
-
-class TestSomething():
- def test_something(self):
- assert True
-# automatic test discovery
-#
-
-def test_something():
- assert True
-
-class TestSomething():
- def test_something(self):
- assert True
-
-# search all test_* and *_test files
-# assert introspection
-#
-
-def test_assert_introspection():
- assert True # assertTrue()
- assert 1 == 1 # assertEqual()
- assert not 1 == 2 # assertNotEqual()
- assert not False # assertFalse()
-# print() debugging
-#
-# stdout is captured for each test, and only printed if the test fails. You can
-# leave your debugging print statments in place to help your future self.
-
-import py
-
-def test_something1():
- print "Useful debugging information."
- assert True
-
- at py.test.mark(xfail="Expected failure.")
-def test_something2():
- print "Useful debugging information."
- assert False
-# exercise 2 (~10 min)
-#
-# TODO: write handout/exercise
-
-def test_one():
- print "debug text"
- assert True
-def test_two():
- assert 1 == 1
- at py.test.mark(xfail="Expected failure.")
-def test_three():
- assert 1 == 2
- at py.test.mark(xfail="Expected failure.")
-def test_four():
- print "debug text"
- assert False
-def test_bonus():
- py.test.raises(ValueError, int, 'foo')
-# exercise 3 (~10 min)
-#
-# TODO: write handout/exercise
-# TODO: use some built-in funcarg for the example
-
-class TestSomething():
- def setup_class(cls):
- pass
- def setup_method(self, method):
- pass
-
- def test_one(self):
- assert True
- def test_two(self):
- assert 1 == 1
-# skipping tests
-#
-
-import py
-
-def test_something_we_want_to_skip():
- py.test.skip("need to decide what it should do.")
- assert something == True
-# generative tests 1
-#
-
-def test_ensure_sufficient_spam1():
- assert 'spam' in 'spam'.lower()
- assert 'spam' in 'SPAM'.lower()
- assert 'spam' in 'eggs & spam'.lower()
- assert 'spam' in 'spammy'.lower()
- assert 'spam' in 'more spam'.lower()
-# generative tests 2
-#
-
-def test_ensure_sufficient_spam2():
- data = ['spam', 'SPAM', 'eggs & spam',
- '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_spam3():
- data = ['spam', 'SPAM', 'eggs & spam',
- 'spammy', 'more spam']
- for item in data:
- yield contains_spam, item
Added: py/extradoc/talk/pycon-us-2009/pytest-introduction/test_hello.py
==============================================================================
--- (empty file)
+++ py/extradoc/talk/pycon-us-2009/pytest-introduction/test_hello.py Thu Mar 26 04:34:52 2009
@@ -0,0 +1,3 @@
+
+def test_hello():
+ assert True
Added: py/extradoc/talk/pycon-us-2009/pytest-introduction/test_trace_setup.py
==============================================================================
--- (empty file)
+++ py/extradoc/talk/pycon-us-2009/pytest-introduction/test_trace_setup.py Thu Mar 26 04:34:52 2009
@@ -0,0 +1,23 @@
+class TestSomething():
+ name = "TestSomething"
+
+ def setup_class(self):
+ print "**setup_class(%s)" % self.name
+
+ def teardown_class(self):
+ print "**teardown_class(%s)" % self.name
+
+ def setup_method(self, method):
+ print "**setup_method(%s)" % (self.name)
+
+ def teardown_method(self, method):
+ print "**teardown_method(%s)" % (self.name)
+
+ def test_true(self):
+ print "**test_true(%s)" % self.name
+ assert True
+
+ def test_equals(self):
+ print "**test_equals(%s)" % self.name
+ assert 1 == 1
+
More information about the pytest-commit
mailing list