[py-svn] r33800 - in py/dist/py: apigen/tracer/testing test/rsession/testing

fijal at codespeak.net fijal at codespeak.net
Fri Oct 27 11:50:30 CEST 2006


Author: fijal
Date: Fri Oct 27 11:50:25 2006
New Revision: 33800

Modified:
   py/dist/py/apigen/tracer/testing/test_package.py
   py/dist/py/test/rsession/testing/test_reporter.py
Log:
Use less sophisticated testing methods.


Modified: py/dist/py/apigen/tracer/testing/test_package.py
==============================================================================
--- py/dist/py/apigen/tracer/testing/test_package.py	(original)
+++ py/dist/py/apigen/tracer/testing/test_package.py	Fri Oct 27 11:50:25 2006
@@ -10,10 +10,7 @@
 
 def setup_module(mod):
     sys.path.insert(0, str(py.path.local(__file__).dirpath().join("package")))
-    try:
-        import submodule
-    except ImportError:
-        py.test.skip("Importing submodule")
+    import submodule
     mod.submodule = submodule
 
 def teardown_module(mod):

Modified: py/dist/py/test/rsession/testing/test_reporter.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_reporter.py	(original)
+++ py/dist/py/test/rsession/testing/test_reporter.py	Fri Oct 27 11:50:25 2006
@@ -10,6 +10,8 @@
 from py.__.test.rsession.testing.test_slave import funcpass_spec, mod_spec
 from py.__.test.rsession.box import Box
 #from py.__.test.
+import sys
+from StringIO import StringIO
 
 def setup_module(mod):
     mod.pkgdir = py.path.local(py.__file__).dirpath()
@@ -45,9 +47,13 @@
             for outcome in outcomes:
                 r.report(ReceivedItemOutcome(None, item, outcome))
         
-        b = Box(boxfun, [config, item, outcomes])
-        b.run()
-        assert b.stdoutrepr == 'FsF.'
+        s = StringIO()
+        stdoutcopy = sys.stdout
+        sys.stdout = s
+        boxfun(config, item, outcomes)
+        sys.stdoud = stdoutcopy
+        
+        assert s.getvalue() == 'FsF.'
 
     def test_module(self):
         config, args = py.test.Config.parse(["some_sub"])
@@ -64,11 +70,14 @@
             for outcome in outcomes:
                 r.report(ReceivedItemOutcome(None, funcitem, outcome))
         
-        b = Box(boxfun, [pkgdir, config, moditem, funcitem, outcomes])
-        b.run()
-        assert b.stdoutrepr.endswith("test_slave.py[8] FsF."),\
-            b.stdoutrepr
-        assert not b.stderrrepr
+        s = StringIO()
+        stdoutcopy = sys.stdout
+        sys.stdout = s
+        boxfun(pkgdir, config, moditem, funcitem, outcomes)
+        sys.stdoud = stdoutcopy
+        
+        assert s.getvalue().endswith("test_slave.py[8] FsF."),\
+            s.getvalue()
 
     def test_full_module(self):
         tmpdir = py.test.ensuretemp("repmod")
@@ -91,9 +100,15 @@
             r = LocalReporter(config, ["localhost"])
             list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
         
-        b = Box(boxfun)
-        b.run()
-        assert b.stdoutrepr == """
+        #b = Box(boxfun)
+        #b.run()
+        s = StringIO()
+        stdoutcopy = sys.stdout
+        sys.stdout = s
+        boxfun()
+        sys.stdoud = stdoutcopy
+        
+        assert s.getvalue() == """
 repmod/test_one.py[1] 
 repmod/test_three.py[0] - FAILED TO LOAD MODULE
 repmod/test_two.py[0] - skipped (reason)"""



More information about the pytest-commit mailing list