1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/9b4dae68a5a4/
Changeset:   9b4dae68a5a4
User:        hpk42
Date:        2013-09-27 15:48:03
Summary:     add terminalreporter.section|line methods to print extra 
information.
Affected #:  5 files

diff -r a9bfa2e8b08d7db4f2d68a63dcf80441666fe818 -r 
9b4dae68a5a41d75bbe4c48b1b5d45806e522717 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -142,7 +142,9 @@
 
 - better parametrize error messages, thanks Brianna Laugher
 
-
+- pytest_terminal_summary(terminalreporter) hooks can now use
+  ".section(title)" and ".line(msg)" methods to print extra 
+  information at the end of a test run.
 
 Changes between 2.3.4 and 2.3.5
 -----------------------------------

diff -r a9bfa2e8b08d7db4f2d68a63dcf80441666fe818 -r 
9b4dae68a5a41d75bbe4c48b1b5d45806e522717 _pytest/hookspec.py
--- a/_pytest/hookspec.py
+++ b/_pytest/hookspec.py
@@ -221,7 +221,7 @@
 pytest_report_teststatus.firstresult = True
 
 def pytest_terminal_summary(terminalreporter):
-    """ add additional section in terminal summary reporting. """
+    """ add additional section in terminal summary reporting.  """
 
 # -------------------------------------------------------------------------
 # doctest hooks

diff -r a9bfa2e8b08d7db4f2d68a63dcf80441666fe818 -r 
9b4dae68a5a41d75bbe4c48b1b5d45806e522717 _pytest/terminal.py
--- a/_pytest/terminal.py
+++ b/_pytest/terminal.py
@@ -100,7 +100,7 @@
         self.startdir = self.curdir = py.path.local()
         if file is None:
             file = py.std.sys.stdout
-        self._tw = py.io.TerminalWriter(file)
+        self._tw = self.writer = py.io.TerminalWriter(file)
         self.currentfspath = None
         self.reportchars = getreportopt(config)
         self.hasmarkup = self._tw.hasmarkup
@@ -148,6 +148,12 @@
         self.ensure_newline()
         self._tw.sep(sep, title, **markup)
 
+    def section(self, title, sep="=", **kw):
+        self._tw.sep(sep, title, **kw)
+
+    def line(self, msg, **kw):
+        self._tw.line(msg, **kw)
+
     def pytest_internalerror(self, excrepr):
         for line in str(excrepr).split("\n"):
             self.write_line("INTERNALERROR> " + line)
@@ -179,6 +185,7 @@
         res = self.config.hook.pytest_report_teststatus(report=rep)
         cat, letter, word = res
         self.stats.setdefault(cat, []).append(rep)
+        self._tests_ran = True
         if not letter and not word:
             # probably passed setup/teardown
             return

diff -r a9bfa2e8b08d7db4f2d68a63dcf80441666fe818 -r 
9b4dae68a5a41d75bbe4c48b1b5d45806e522717 testing/test_mark.py
--- a/testing/test_mark.py
+++ b/testing/test_mark.py
@@ -317,7 +317,7 @@
                 request.applymarker(pytest.mark.hello)
             def pytest_terminal_summary(terminalreporter):
                 l = terminalreporter.stats['passed']
-                terminalreporter._tw.line("keyword: %s" % l[0].keywords)
+                terminalreporter.writer.line("keyword: %s" % l[0].keywords)
         """)
         testdir.makepyfile("""
             def test_func(arg):

diff -r a9bfa2e8b08d7db4f2d68a63dcf80441666fe818 -r 
9b4dae68a5a41d75bbe4c48b1b5d45806e522717 testing/test_terminal.py
--- a/testing/test_terminal.py
+++ b/testing/test_terminal.py
@@ -699,3 +699,16 @@
     result.stdout.fnmatch_lines([
             '*File *test_tbstyle_native_setup_error.py", line *, in 
setup_error_fixture*'
             ])
+
+def test_terminal_summary(testdir):
+    testdir.makeconftest("""
+        def pytest_terminal_summary(terminalreporter):
+            w = terminalreporter
+            w.section("hello")
+            w.line("world")
+    """)
+    result = testdir.runpytest()
+    result.stdout.fnmatch_lines("""
+        *==== hello ====*
+        world
+    """)

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.
_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to