Commits

holger krekel  committed ec8b1b5

trying to go final

  • Participants
  • Parent commits 61e9a35

Comments (0)

Files changed (6)

 py.process.cmdexec("zip -r %s %s" % (zipname, tdir.basename))
 print "created", zipname
 
-out = py.process.cmdexec("scp %s code:/www/codespeak.net/htdocs/py/dist/test/tutorial/" % zipname)
-print out
+#out = py.process.cmdexec("scp %s code:/www/codespeak.net/htdocs/py/dist/test/tutorial/" % zipname)
+#print out
 

File param/conftest.py

+import py
+
+def pytest_generate_tests(metafunc):
+    multi = getattr(metafunc.function, 'multi', None)
+    if multi is not None:
+        assert len(multi.kwargs) == 1
+        for name, l in multi.kwargs.items():
+            for val in l:
+                metafunc.addcall(id=str(val), funcargs={name: val})

File param/test_param.py

+
+import py
+
+@py.test.mark.multi(arg1=[1,2,3])
+def test_hello(arg1):
+    assert arg1 < 3
+

File pytest-advanced.pdf

Binary file modified.

File pytest-advanced.txt

 on test functions and allows to generate multiple invocations using
 different parameter sets. 
 
-**simple interactive example**
-
-
-Example: re-running with multiple argument values
-=======================================================
-
-say we want the following test function and marker::
-
-    @py.test.mark.multi(urlprefix=['http', 'https'])
-    def test_function(urlprefix):
-        assert urlprefix.startswith("http")
-
-to trigger our test function to be called twice::
-    
-    test_function(urlprefix='http')
-    test_function(urlprefix='https')
    
 Example hook for re-running with multiple args
 ====================================================
                 metafunc.addcall(funcargs={name: val})
 
 Let's put this into a ``conftest.py`` or directly into 
-the test module file ... 
+the test module file ... (see example ``param``)
 
 
-Exercise: add some parametrization to myscan 
-====================================================
+Example: re-running with multiple argument values
+=======================================================
 
-base files are in ``5/*`` directory. exercise is to:
+in directory ``6`` the multi-marker is implemented and used::
 
-- add the above "multi" parametrizer to ``5/test/conftest.py``
+    @py.test.mark.multi(urlprefix=['http', 'https'])
+    def test_function(urlprefix):
+        assert urlprefix.startswith("http")
 
-- add an ``urlprefix`` parameter to 
-  ``5/test/test_myscan.py::test_checkremote``
-
-- add a "multi" marker aka 
-  ``@py.test.mark.multi(urlprefix=['http', 'https'])`` 
-  to the same test function and modify the test code 
-  to use the ``urlprefix`` parameter. 
-
-- run ``py.test --checkremote --collectonly`` 
-
-- run ``py.test --checkremote`` 
+to trigger our test function to be called twice::
+    
+    test_function(urlprefix='http')
+    test_function(urlprefix='https')
 
 Server Example: setups spanning a test session 
 ====================================================

File pytest-basic.pdf

Binary file modified.