[Pytest-commit] commit/pytest: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Apr 14 20:31:13 CEST 2014


3 new commits in pytest:

https://bitbucket.org/hpk42/pytest/commits/69043f0b8025/
Changeset:   69043f0b8025
Branch:      issue499
User:        rouge8
Date:        2014-04-14 18:27:55
Summary:     fix issue499: document selecting tests by node ID
Affected #:  2 files

diff -r 9eeb7bb8cf81ebd997907ef43f57b4151fd6c002 -r 69043f0b802502e544ad60b07c4a4c63aa988231 doc/en/example/markers.txt
--- a/doc/en/example/markers.txt
+++ b/doc/en/example/markers.txt
@@ -21,6 +21,9 @@
         pass
     def test_another():
         pass
+    class TestClass:
+        def test_method(self):
+            pass
 
 .. versionadded:: 2.2
 
@@ -29,25 +32,79 @@
     $ py.test -v -m webtest
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:3: test_send_http PASSED
     
-    =================== 2 tests deselected by "-m 'webtest'" ===================
-    ================== 1 passed, 2 deselected in 0.01 seconds ==================
+    =================== 3 tests deselected by "-m 'webtest'" ===================
+    ================== 1 passed, 3 deselected in 0.01 seconds ==================
 
 Or the inverse, running all tests except the webtest ones::
 
     $ py.test -v -m "not webtest"
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:6: test_something_quick PASSED
     test_server.py:8: test_another PASSED
+    test_server.py:11: TestClass.test_method PASSED
     
     ================= 1 tests deselected by "-m 'not webtest'" =================
-    ================== 2 passed, 1 deselected in 0.01 seconds ==================
+    ================== 3 passed, 1 deselected in 0.01 seconds ==================
+
+Selecing tests based on their node ID
+-------------------------------------
+
+You can provide one or more node IDs as positional arguments to select
+only specified tests. This makes it easy to select tests based on
+their module, class, method, or function name::
+
+    $ py.test -v test_server.py::TestClass::test_method
+    =========================== test session starts ============================
+    platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
+    collecting ... collected 4 items
+
+    test_server.py:11: TestClass.test_method PASSED
+
+    ========================= 1 passed in 0.01 seconds =========================
+
+You can also select on the class::
+
+    $ py.test -v test_server.py::TestClass
+    =========================== test session starts ============================
+    platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
+    collecting ... collected 4 items
+
+    test_server.py:11: TestClass.test_method PASSED
+
+    ========================= 1 passed in 0.01 seconds =========================
+
+Or select multiple nodes::
+
+  $ py.test -v test_server.py::TestClass test_server.py::test_send_http
+    =========================== test session starts ============================
+    platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
+    collecting ... collected 8 items
+
+    test_server.py:11: TestClass.test_method PASSED
+    test_server.py:3: test_send_http PASSED
+
+    ========================= 2 passed in 0.01 seconds =========================
+
+.. note::
+
+    Node IDs are of the form ``module.py::class::method`` or
+    ``module.py::function``.  Node IDs control which tests are
+    collected, so ``module.py::class`` will select all test methods
+    on the class.  Nodes are also created for each parameter of a
+    parametrized fixture or test, so selecting a parametrized test
+    must include the parameter value, e.g.
+    ``module.py::function[param]``.
+
+    Node IDs for failing tests are displayed in the test summary info
+    when running py.test with the ``-rf`` option.  You can also
+    construct Node IDs from the output of ``py.test --collectonly``.
 
 Using ``-k expr`` to select tests based on their name
 -------------------------------------------------------
@@ -62,38 +119,39 @@
     $ py.test -v -k http  # running with the above defined example module
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:3: test_send_http PASSED
     
-    ====================== 2 tests deselected by '-khttp' ======================
-    ================== 1 passed, 2 deselected in 0.01 seconds ==================
+    ====================== 3 tests deselected by '-khttp' ======================
+    ================== 1 passed, 3 deselected in 0.01 seconds ==================
 
 And you can also run all tests except the ones that match the keyword::
 
     $ py.test -k "not send_http" -v
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:6: test_something_quick PASSED
     test_server.py:8: test_another PASSED
+    test_server.py:11: TestClass.test_method PASSED
     
     ================= 1 tests deselected by '-knot send_http' ==================
-    ================== 2 passed, 1 deselected in 0.01 seconds ==================
+    ================== 3 passed, 1 deselected in 0.01 seconds ==================
 
 Or to select "http" and "quick" tests::
 
     $ py.test -k "http or quick" -v
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:3: test_send_http PASSED
     test_server.py:6: test_something_quick PASSED
     
-    ================= 1 tests deselected by '-khttp or quick' ==================
-    ================== 2 passed, 1 deselected in 0.01 seconds ==================
+    ================= 2 tests deselected by '-khttp or quick' ==================
+    ================== 2 passed, 2 deselected in 0.01 seconds ==================
 
 .. note::
 

diff -r 9eeb7bb8cf81ebd997907ef43f57b4151fd6c002 -r 69043f0b802502e544ad60b07c4a4c63aa988231 doc/en/usage.txt
--- a/doc/en/usage.txt
+++ b/doc/en/usage.txt
@@ -49,6 +49,9 @@
                           # the "string expression", e.g. "MyClass and not method" 
                           # will select TestMyClass.test_something
                           # but not TestMyClass.test_method_simple
+    py.test test_mod.py::test_func  # only run tests that match the "node ID",
+                                    # e.g "test_mod.py::test_func" will select
+                                    # only test_func in test_mod.py
 
 Import 'pkg' and use its filesystem location to find and run tests::
 


https://bitbucket.org/hpk42/pytest/commits/23b99e4408fd/
Changeset:   23b99e4408fd
Branch:      issue499
User:        rouge8
Date:        2014-04-14 20:24:13
Summary:     Interal link to node ID explanation
Affected #:  1 file

diff -r 69043f0b802502e544ad60b07c4a4c63aa988231 -r 23b99e4408fd903370e9ecdbd34a964aaeede684 doc/en/example/markers.txt
--- a/doc/en/example/markers.txt
+++ b/doc/en/example/markers.txt
@@ -56,9 +56,9 @@
 Selecing tests based on their node ID
 -------------------------------------
 
-You can provide one or more node IDs as positional arguments to select
-only specified tests. This makes it easy to select tests based on
-their module, class, method, or function name::
+You can provide one or more :ref:`node IDs <node-id>` as positional
+arguments to select only specified tests. This makes it easy to select
+tests based on their module, class, method, or function name::
 
     $ py.test -v test_server.py::TestClass::test_method
     =========================== test session starts ============================
@@ -92,6 +92,9 @@
 
     ========================= 2 passed in 0.01 seconds =========================
 
+
+.. _node-id:
+
 .. note::
 
     Node IDs are of the form ``module.py::class::method`` or


https://bitbucket.org/hpk42/pytest/commits/a00590d97593/
Changeset:   a00590d97593
User:        flub
Date:        2014-04-14 20:31:07
Summary:     Merged in rouge8/pytest/issue499 (pull request #157)

fix issue499: document selecting tests by node ID
Affected #:  2 files

diff -r 9eeb7bb8cf81ebd997907ef43f57b4151fd6c002 -r a00590d97593d00163772511aca3149f7ef0bae2 doc/en/example/markers.txt
--- a/doc/en/example/markers.txt
+++ b/doc/en/example/markers.txt
@@ -21,6 +21,9 @@
         pass
     def test_another():
         pass
+    class TestClass:
+        def test_method(self):
+            pass
 
 .. versionadded:: 2.2
 
@@ -29,25 +32,82 @@
     $ py.test -v -m webtest
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:3: test_send_http PASSED
     
-    =================== 2 tests deselected by "-m 'webtest'" ===================
-    ================== 1 passed, 2 deselected in 0.01 seconds ==================
+    =================== 3 tests deselected by "-m 'webtest'" ===================
+    ================== 1 passed, 3 deselected in 0.01 seconds ==================
 
 Or the inverse, running all tests except the webtest ones::
 
     $ py.test -v -m "not webtest"
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:6: test_something_quick PASSED
     test_server.py:8: test_another PASSED
+    test_server.py:11: TestClass.test_method PASSED
     
     ================= 1 tests deselected by "-m 'not webtest'" =================
-    ================== 2 passed, 1 deselected in 0.01 seconds ==================
+    ================== 3 passed, 1 deselected in 0.01 seconds ==================
+
+Selecing tests based on their node ID
+-------------------------------------
+
+You can provide one or more :ref:`node IDs <node-id>` as positional
+arguments to select only specified tests. This makes it easy to select
+tests based on their module, class, method, or function name::
+
+    $ py.test -v test_server.py::TestClass::test_method
+    =========================== test session starts ============================
+    platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
+    collecting ... collected 4 items
+
+    test_server.py:11: TestClass.test_method PASSED
+
+    ========================= 1 passed in 0.01 seconds =========================
+
+You can also select on the class::
+
+    $ py.test -v test_server.py::TestClass
+    =========================== test session starts ============================
+    platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
+    collecting ... collected 4 items
+
+    test_server.py:11: TestClass.test_method PASSED
+
+    ========================= 1 passed in 0.01 seconds =========================
+
+Or select multiple nodes::
+
+  $ py.test -v test_server.py::TestClass test_server.py::test_send_http
+    =========================== test session starts ============================
+    platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
+    collecting ... collected 8 items
+
+    test_server.py:11: TestClass.test_method PASSED
+    test_server.py:3: test_send_http PASSED
+
+    ========================= 2 passed in 0.01 seconds =========================
+
+
+.. _node-id:
+
+.. note::
+
+    Node IDs are of the form ``module.py::class::method`` or
+    ``module.py::function``.  Node IDs control which tests are
+    collected, so ``module.py::class`` will select all test methods
+    on the class.  Nodes are also created for each parameter of a
+    parametrized fixture or test, so selecting a parametrized test
+    must include the parameter value, e.g.
+    ``module.py::function[param]``.
+
+    Node IDs for failing tests are displayed in the test summary info
+    when running py.test with the ``-rf`` option.  You can also
+    construct Node IDs from the output of ``py.test --collectonly``.
 
 Using ``-k expr`` to select tests based on their name
 -------------------------------------------------------
@@ -62,38 +122,39 @@
     $ py.test -v -k http  # running with the above defined example module
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:3: test_send_http PASSED
     
-    ====================== 2 tests deselected by '-khttp' ======================
-    ================== 1 passed, 2 deselected in 0.01 seconds ==================
+    ====================== 3 tests deselected by '-khttp' ======================
+    ================== 1 passed, 3 deselected in 0.01 seconds ==================
 
 And you can also run all tests except the ones that match the keyword::
 
     $ py.test -k "not send_http" -v
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:6: test_something_quick PASSED
     test_server.py:8: test_another PASSED
+    test_server.py:11: TestClass.test_method PASSED
     
     ================= 1 tests deselected by '-knot send_http' ==================
-    ================== 2 passed, 1 deselected in 0.01 seconds ==================
+    ================== 3 passed, 1 deselected in 0.01 seconds ==================
 
 Or to select "http" and "quick" tests::
 
     $ py.test -k "http or quick" -v
     =========================== test session starts ============================
     platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /home/hpk/p/pytest/.tox/regen/bin/python
-    collecting ... collected 3 items
+    collecting ... collected 4 items
     
     test_server.py:3: test_send_http PASSED
     test_server.py:6: test_something_quick PASSED
     
-    ================= 1 tests deselected by '-khttp or quick' ==================
-    ================== 2 passed, 1 deselected in 0.01 seconds ==================
+    ================= 2 tests deselected by '-khttp or quick' ==================
+    ================== 2 passed, 2 deselected in 0.01 seconds ==================
 
 .. note::
 

diff -r 9eeb7bb8cf81ebd997907ef43f57b4151fd6c002 -r a00590d97593d00163772511aca3149f7ef0bae2 doc/en/usage.txt
--- a/doc/en/usage.txt
+++ b/doc/en/usage.txt
@@ -49,6 +49,9 @@
                           # the "string expression", e.g. "MyClass and not method" 
                           # will select TestMyClass.test_something
                           # but not TestMyClass.test_method_simple
+    py.test test_mod.py::test_func  # only run tests that match the "node ID",
+                                    # e.g "test_mod.py::test_func" will select
+                                    # only test_func in test_mod.py
 
 Import 'pkg' and use its filesystem location to find and run tests::

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list