From 65a04bc3be5e452ed0336df30929dc4aa2cde079 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 13 May 2009 01:55:11 +0200 Subject: [PATCH] simplify example code --HG-- branch : trunk --- doc/test/funcargs.txt | 12 +++++------- example/funcarg/mysetup/conftest.py | 4 +--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/test/funcargs.txt b/doc/test/funcargs.txt index bad5aef12..2ddee3b4d 100644 --- a/doc/test/funcargs.txt +++ b/doc/test/funcargs.txt @@ -81,7 +81,7 @@ If you run this with ``py.test test_simpleprovider.py`` you see something like t This means that the test function got executed and the assertion failed. Here is how py.test comes to execute this test function: -1. py.test discovers the ``test_function`` because of the ``test_prefix``. +1. py.test discovers the ``test_function`` because of the ``test_`` prefix. The test function needs a function argument named ``myfuncarg``. A matching provider function is discovered by looking for the special name ``pytest_funcarg__myfuncarg``. @@ -312,15 +312,13 @@ following code into a local ``conftest.py``: class ConftestPlugin: def pytest_funcarg__mysetup(self, request): - return MySetup(request) + return MySetup() class MySetup: - def __init__(self, request): - self.config = request.config def myapp(self): return MyApp() - -To run the example we put a pseudo MyApp object into ``myapp.py``: + +To run the example we represent our application by putting a pseudo MyApp object into ``myapp.py``: .. sourcecode:: python @@ -412,7 +410,7 @@ Now any test function can use the ``mysetup.getsshconnection()`` method like thi conn = mysetup.getsshconnection() # work with conn -Running this without specifying a command line option will result in a skipped test_function: +Running ``py.test test_ssh.py`` without specifying a command line option will result in a skipped test_function: .. sourcecode:: python diff --git a/example/funcarg/mysetup/conftest.py b/example/funcarg/mysetup/conftest.py index 7b156c7be..c62df898d 100644 --- a/example/funcarg/mysetup/conftest.py +++ b/example/funcarg/mysetup/conftest.py @@ -3,10 +3,8 @@ from myapp import MyApp class ConftestPlugin: def pytest_funcarg__mysetup(self, request): - return MySetup(request) + return MySetup() class MySetup: - def __init__(self, request): - self.config = request.config def myapp(self): return MyApp()