[py-svn] r58104 - py/extradoc/talk/pycon-uk-2008

hpk at codespeak.net hpk at codespeak.net
Sat Sep 13 14:42:53 CEST 2008


Author: hpk
Date: Sat Sep 13 14:42:52 2008
New Revision: 58104

Modified:
   py/extradoc/talk/pycon-uk-2008/pytest.txt
Log:
some streamlining, updates jit before the talk


Modified: py/extradoc/talk/pycon-uk-2008/pytest.txt
==============================================================================
--- py/extradoc/talk/pycon-uk-2008/pytest.txt	(original)
+++ py/extradoc/talk/pycon-uk-2008/pytest.txt	Sat Sep 13 14:42:52 2008
@@ -61,9 +61,9 @@
 Write and run basic tests 
 ===================================
 
-example from ``py/path/local/testing/test_local.py``::
+real life example:
 
-   def test_pypkgdir():
+   def test_pypkpath():
      datadir = py.test.ensuretemp("pypkgdir")
      pkg = datadir.ensure('pkg1', dir=1)
      pkg.ensure("__init__.py")
@@ -76,7 +76,7 @@
 Putting tests in Test Classes
 ==================================
 
-example from ``py/path/local/testing/test_local.py``::
+real life example:
 
  class TestExecutionOnWindows(LocalSetup):
    disabled = py.std.sys.platform != 'win32'
@@ -92,7 +92,6 @@
 ========================
 
 - py.test automatically collects ``test_*`` functions 
-- use ``py.test --collectonly`` to inspect collection 
 - you can write tests at module global level 
 - assertion failures provide detailed info 
 
@@ -124,18 +123,18 @@
 =======================================
 
 meet ``py.test --looponfailing``:
-  - does a full test run 
-  - keeps a set of failing tests 
-  - checks for file changes and re-runs failing tests 
-  - if all failures are fixed, re-run the whole 
 
-great for refactoring!
+- does a full test run 
+- keeps a set of failing tests 
+- checks for file changes and re-runs failing tests 
+- if all failures fixed, reruns whole test suite
 
+great for refactoring!
 
 Setup and Teardown of test state
 ==================================
 
-look again at the above ``test_local.py``::
+again example from ``test_local.py``::
 
   class LocalSetup:
     def setup_class(cls):
@@ -150,15 +149,14 @@
 Skipping tests 
 ===================
 
-Sometimes you need to skip test, use ``py.test.skip``:: 
+Sometimes you need to skip a test, use ``py.test.skip``:: 
 
-  class TestSomeClass:
-    def setup_class(cls):
+  def test_something_on_windows():
       if sys.platform == "win32":
           py.test.skip("win32 required")
+       ...
 
-you can also place such calls to "py.test.skip()" inside test functions
-or in other test setup functions. 
+you can also place such calls to "py.test.skip()" in setup functions. 
 
 Doctests 
 =================
@@ -175,37 +173,43 @@
 Customizing py.test 
 ===========================
 
-write "confest.py" files at project or global level: 
-
-- integrate new test "items" or "collectors" 
+- modify/extend the test collection process 
 - add command line options 
-- influence the collection process 
+- register to reporting events (trunk/1.0)
+- write conftest.py files 
 - for debugging:: 
 
     py.test --collectonly 
     py.test --traceconfig 
 
+The collection tree
+===========================
 
-Important Internal Objects
+- items: runnable tests - ``item.runtest()``
+- collectors: return collectors or items - ``collector.collect()``
+- collection tree is built iteratively
+- test collection starts from directories or files (via cmdline)
+- test collection not limited to Python files! 
+- use ``py.test --collectonly`` for debugging
+
+Important Collection Objects
 ==================================
 
-- **Session**: iterates over (custom) collection tree, executes tests and reports outcomes. 
 - **Directory** collect files in directory
+- **FSCollector** a Collector for a File 
 - **Module** collect python Classes and Functions 
 - **Class**/**Instance** collect test methods 
 - **Generator** collect generative tests 
 - **Function** sets up and executes a python test function 
 - **DoctestFile** collect doctests in a .txt file 
 
-The collection tree
-===========================
-
-- leaves: so called "items", e.g. ``py.test.collect.Function``
-- nodes: so called "collectors" contain further collectors or items 
-- collection tree is built iterativels
-- test collection usually starts from directories or files 
-- **dynamic lookup in conftest.py files**
+Conftest.py files
+==========================
 
+- place ``conftest.py`` files in a directory
+- project root, subdir or home directory
+- collectors/items are looked up in **nearest conftest.py** file. 
+- this means: **project specific or global extensions**
 
 Example conftest.py: add ReST check support 
 ==============================================
@@ -213,9 +217,8 @@
 look into ``py/doc/conftest.py``:
 
 - this produces non-python test items
-- ``py.test --collectonly`` shows the custom tree
 - produces syntax and link checks 
-- drop the conftest.py file into your own project/doc directory 
+- drop the conftest.py file into your own project/doc directory!
 
 Example conftest.py: html page generation 
 ===========================================
@@ -254,7 +257,7 @@
 
 [courtesy Holger Krekel]
 
-- goal: remotely run tests on windows 
+- goal: remotely run tests on windows from linux
 - check out py/misc/conftest-socketgatewayrun.py
 - requires a small server script on the windows side 
 - transfers your source code to windows, runs tests, 
@@ -280,14 +283,12 @@
 
 - you can extend and modify the collection process 
 - you can add new (non-python) test items 
-- conftest.py files are usually "drop in" plugins
-- often project independent
-- **orthogonality** of conftest features 
+- conftest.py files are meant to be "drop in" plugins
 
-but note: 
+note: 
 
-- customization gets easier with the upcoming 1.0 release, 
-  please subscribe to http://codespeak.net/mailman/listinfo/py-dev
+- customization easier with upcoming 1.0 release, 
+  use py/trunk instead of 0.9.2 release 
 
 recap: main features 
 ======================
@@ -311,5 +312,6 @@
 
 http://pylib.org  http://pytest.org
 
-http://merlinux.eu - holger at merlinux.eu 
+http://merlinux.eu - holger at merlinux.de 
 
+https://codespeak.net/svn/py/extradoc/talk/ep2008/pytest.txt



More information about the pytest-commit mailing list