probably the last major internal cleanup action: rename collection to

session which now is the root collection node.  This means that
session, collection and config objects have a more defined
relationship (previously there was no way to get from a collection
node or even from a runtest hook to the session object which
was strange).
This commit is contained in:
holger krekel
2010-11-07 10:19:58 +01:00
parent 722e20c7d6
commit 6461295ab4
29 changed files with 163 additions and 143 deletions
+2 -2
View File
@@ -27,10 +27,10 @@ Let's run our little function::
F
================================= FAILURES =================================
______________________________ test_something ______________________________
def test_something():
> checkconfig(42)
E Failed: not configured: 42
test_checkconfig.py:8: Failed
1 failed in 0.02 seconds
+3 -3
View File
@@ -36,12 +36,12 @@ and when running it will see a skipped "slow" test::
$ py.test test_module.py -rs # "-rs" means report on the little 's'
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev19
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev22
test path 1: test_module.py
test_module.py .s
========================= short test summary info ==========================
SKIP [1] /tmp/doc-exec-435/conftest.py:9: need --runslow option to run
SKIP [1] /tmp/doc-exec-557/conftest.py:9: need --runslow option to run
=================== 1 passed, 1 skipped in 0.02 seconds ====================
@@ -49,7 +49,7 @@ Or run it including the ``slow`` marked test::
$ py.test test_module.py --runslow
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev19
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev22
test path 1: test_module.py
test_module.py ..
+5 -5
View File
@@ -49,7 +49,7 @@ You can now run the test::
$ py.test test_sample.py
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev19
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev22
test path 1: test_sample.py
test_sample.py F
@@ -57,7 +57,7 @@ You can now run the test::
================================= FAILURES =================================
_______________________________ test_answer ________________________________
mysetup = <conftest.MySetup instance at 0x1cf6b90>
mysetup = <conftest.MySetup instance at 0x1ca5cf8>
def test_answer(mysetup):
app = mysetup.myapp()
@@ -122,14 +122,14 @@ Running it yields::
$ py.test test_ssh.py -rs
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev19
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev22
test path 1: test_ssh.py
test_ssh.py s
========================= short test summary info ==========================
SKIP [1] /tmp/doc-exec-438/conftest.py:22: specify ssh host with --ssh
SKIP [1] /tmp/doc-exec-560/conftest.py:22: specify ssh host with --ssh
======================== 1 skipped in 0.02 seconds =========================
======================== 1 skipped in 0.03 seconds =========================
If you specify a command line option like ``py.test --ssh=python.org`` the test will execute as expected.
+11 -8
View File
@@ -27,17 +27,19 @@ now execute the test specification::
nonpython $ py.test test_simple.yml
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev19
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev22
test path 1: test_simple.yml
test_simple.yml .F
================================= FAILURES =================================
______________________________ usecase: hello ______________________________
usecase execution failed
spec failed: 'some': 'other'
no further details known at this point.
==================== 1 failed, 1 passed in 0.42 seconds ====================
========================= short test summary info ==========================
FAIL test_simple.yml::hello
==================== 1 failed, 1 passed in 0.43 seconds ====================
You get one dot for the passing ``sub1: sub1`` check and one failure.
Obviously in the above ``conftest.py`` you'll want to implement a more
@@ -56,24 +58,25 @@ reporting in ``verbose`` mode::
nonpython $ py.test -v
=========================== test session starts ============================
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev19 -- /home/hpk/venv/0/bin/python
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev22 -- /home/hpk/venv/0/bin/python
test path 1: /home/hpk/p/pytest/doc/example/nonpython
test_simple.yml <- test_simple.yml:1: usecase: ok PASSED
test_simple.yml <- test_simple.yml:1: usecase: hello FAILED
================================= FAILURES =================================
______________________________ usecase: hello ______________________________
usecase execution failed
spec failed: 'some': 'other'
no further details known at this point.
========================= short test summary info ==========================
FAIL test_simple.yml::hello
==================== 1 failed, 1 passed in 0.07 seconds ====================
While developing your custom test collection and execution it's also
interesting to just look at the collection tree::
nonpython $ py.test --collectonly
<Collection 'nonpython'>
<YamlFile 'test_simple.yml'>
<YamlItem 'ok'>
<YamlItem 'hello'>
-1
View File
@@ -31,7 +31,6 @@ finding out what is collected
You can always peek at the collection tree without running tests like this::
. $ py.test --collectonly collectonly.py
<Collection 'example'>
<Module 'collectonly.py'>
<Function 'test_function'>
<Class 'TestClass'>
+1 -1
View File
@@ -130,7 +130,7 @@ let's run the full monty::
E assert 4 < 4
test_compute.py:3: AssertionError
1 failed, 4 passed in 0.02 seconds
1 failed, 4 passed in 0.03 seconds
As expected when running the full range of ``param1`` values
we'll get an error on the last one.