[py-svn] commit/pytest: hpk42: report keyboardintterupt even if inteerrupted during sessionstartup

Bitbucket commits-noreply at bitbucket.org
Thu Jul 7 21:24:19 CEST 2011


1 new changeset in pytest:

http://bitbucket.org/hpk42/pytest/changeset/3a0ef7bc4b7f/
changeset:   3a0ef7bc4b7f
user:        hpk42
date:        2011-07-07 21:24:09
summary:     report keyboardintterupt even if inteerrupted during sessionstartup
affected #:  3 files (657 bytes)

--- a/CHANGELOG	Thu Jul 07 21:15:35 2011 +0200
+++ b/CHANGELOG	Thu Jul 07 21:24:09 2011 +0200
@@ -15,6 +15,7 @@
 - fix issue44: env/username expansion for junitxml file path
 - show releaselevel information in test runs for pypy
 - reworked doc pages for better navigation and PDF generation
+- report KeyboardInterrupt even if interrupted during session startup
 
 Changes between 2.0.2 and 2.0.3
 ----------------------------------------------


--- a/_pytest/terminal.py	Thu Jul 07 21:15:35 2011 +0200
+++ b/_pytest/terminal.py	Thu Jul 07 21:24:09 2011 +0200
@@ -318,12 +318,17 @@
             self.config.hook.pytest_terminal_summary(terminalreporter=self)
         if exitstatus == 2:
             self._report_keyboardinterrupt()
+            del self._keyboardinterrupt_memo
         self.summary_deselected()
         self.summary_stats()
 
     def pytest_keyboard_interrupt(self, excinfo):
         self._keyboardinterrupt_memo = excinfo.getrepr(funcargs=True)
 
+    def pytest_unconfigure(self):
+        if hasattr(self, '_keyboardinterrupt_memo'):
+            self._report_keyboardinterrupt()
+
     def _report_keyboardinterrupt(self):
         excrepr = self._keyboardinterrupt_memo
         msg = excrepr.reprcrash.message


--- a/testing/test_terminal.py	Thu Jul 07 21:15:35 2011 +0200
+++ b/testing/test_terminal.py	Thu Jul 07 21:24:09 2011 +0200
@@ -167,6 +167,19 @@
             ])
         result.stdout.fnmatch_lines(['*KeyboardInterrupt*'])
 
+    def test_keyboard_in_sessionstart(self, testdir):
+        testdir.makeconftest("""
+            def pytest_sessionstart():
+                raise KeyboardInterrupt
+        """)
+        p = testdir.makepyfile("""
+            def test_foobar():
+                pass
+        """)
+
+        result = testdir.runpytest()
+        assert result.ret == 2
+        result.stdout.fnmatch_lines(['*KeyboardInterrupt*'])
 
 
 class TestCollectonly:

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.



More information about the pytest-commit mailing list