From 6ffb6592827e59a4b43f6a580fe0775230624e48 Mon Sep 17 00:00:00 2001 From: Evan Bender Date: Fri, 4 Sep 2015 15:11:57 -0400 Subject: [PATCH] Document single-method usage It is possible to run a single test method in a class, but the syntax is not glaringly obvious and documentation would help people out. --- doc/en/usage.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 85478d51c..54ad72bb1 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -46,12 +46,14 @@ Several test run options:: py.test test_mod.py # run tests in module py.test somepath # run all tests below somepath py.test -k stringexpr # only run tests with names that match the - # the "string expression", e.g. "MyClass and not method" + # 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 + py.test test_mod.py::TestClass::test_method # run a single method in + # a single class Import 'pkg' and use its filesystem location to find and run tests:: @@ -87,7 +89,7 @@ failure situation:: py.test -x --pdb # drop to PDB on first failure, then end test session py.test --pdb --maxfail=3 # drop to PDB for first three failures -Note that on any failure the exception information is stored on +Note that on any failure the exception information is stored on ``sys.last_value``, ``sys.last_type`` and ``sys.last_traceback``. In interactive use, this allows one to drop into postmortem debugging with any debug tool. One can also manually access the exception information, @@ -260,6 +262,6 @@ hook was invoked:: $ python myinvoke.py *** test run reporting finishing - + .. include:: links.inc