[Pytest-commit] commit/pytest: RonnyPfannschmidt: Merged in hpk42/pytest-patches/plug30 (pull request #291)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu May 7 11:24:44 CEST 2015


1 new commit in pytest:

https://bitbucket.org/pytest-dev/pytest/commits/cf2f646d6578/
Changeset:   cf2f646d6578
User:        RonnyPfannschmidt
Date:        2015-05-07 09:24:39+00:00
Summary:     Merged in hpk42/pytest-patches/plug30 (pull request #291)

use new pluggy api (now at 0.3.0) for adding hookcall monitoring
Affected #:  4 files

diff -r af98ffcfb0fb1d0116bfc4b46c49dfa31fdfc7c2 -r cf2f646d6578e354dd3c0ea45aba31f74b9cd5ff _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
 #
-__version__ = '2.8.0.dev3'
+__version__ = '2.8.0.dev4'

diff -r af98ffcfb0fb1d0116bfc4b46c49dfa31fdfc7c2 -r cf2f646d6578e354dd3c0ea45aba31f74b9cd5ff _pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -13,7 +13,6 @@
 import py
 import pytest
 from py.builtin import print_
-from pluggy import _TracedHookExecution
 
 from _pytest.main import Session, EXIT_OK
 
@@ -194,12 +193,13 @@
         self._pluginmanager = pluginmanager
         self.calls = []
 
-        def before(hook, method, kwargs):
-            self.calls.append(ParsedCall(hook.name, kwargs))
-        def after(outcome, hook, method, kwargs):
+        def before(hook_name, hook_impls, kwargs):
+            self.calls.append(ParsedCall(hook_name, kwargs))
+
+        def after(outcome, hook_name, hook_impls, kwargs):
             pass
-        executor = _TracedHookExecution(pluginmanager, before, after)
-        self._undo_wrapping = executor.undo
+
+        self._undo_wrapping = pluginmanager.add_hookcall_monitoring(before, after)
 
     def finish_recording(self):
         self._undo_wrapping()
@@ -667,6 +667,7 @@
         class Collect:
             def pytest_configure(x, config):
                 rec.append(self.make_hook_recorder(config.pluginmanager))
+
         plugins = kwargs.get("plugins") or []
         plugins.append(Collect())
         ret = pytest.main(list(args), plugins=plugins)
@@ -677,6 +678,13 @@
             class reprec:
                 pass
         reprec.ret = ret
+
+        # typically we reraise keyboard interrupts from the child run
+        # because it's our user requesting interruption of the testing
+        if ret == 2 and not kwargs.get("no_reraise_ctrlc"):
+            calls = reprec.getcalls("pytest_keyboard_interrupt")
+            if calls and calls[-1].excinfo.type == KeyboardInterrupt:
+                raise KeyboardInterrupt()
         return reprec
 
     def runpytest_inprocess(self, *args, **kwargs):
@@ -688,7 +696,7 @@
         capture = py.io.StdCapture()
         try:
             try:
-                reprec = self.inline_run(*args)
+                reprec = self.inline_run(*args, **kwargs)
             except SystemExit as e:
                 class reprec:
                     ret = e.args[0]

diff -r af98ffcfb0fb1d0116bfc4b46c49dfa31fdfc7c2 -r cf2f646d6578e354dd3c0ea45aba31f74b9cd5ff setup.py
--- a/setup.py
+++ b/setup.py
@@ -48,7 +48,7 @@
 
 
 def main():
-    install_requires = ['py>=1.4.27.dev2', 'pluggy>=0.2.0,<0.3.0']
+    install_requires = ['py>=1.4.27.dev2', 'pluggy>=0.3.0,<0.4.0']
     extras_require = {}
     if has_environment_marker_support():
         extras_require[':python_version=="2.6" or python_version=="3.0" or python_version=="3.1"'] = ['argparse']

diff -r af98ffcfb0fb1d0116bfc4b46c49dfa31fdfc7c2 -r cf2f646d6578e354dd3c0ea45aba31f74b9cd5ff testing/test_terminal.py
--- a/testing/test_terminal.py
+++ b/testing/test_terminal.py
@@ -132,8 +132,8 @@
         ])
 
     def test_itemreport_directclasses_not_shown_as_subclasses(self, testdir):
-        a = testdir.mkpydir("a")
-        a.join("test_hello.py").write(py.code.Source("""
+        a = testdir.mkpydir("a123")
+        a.join("test_hello123.py").write(py.code.Source("""
             class TestClass:
                 def test_method(self):
                     pass
@@ -141,7 +141,7 @@
         result = testdir.runpytest("-v")
         assert result.ret == 0
         result.stdout.fnmatch_lines([
-            "*a/test_hello.py*PASS*",
+            "*a123/test_hello123.py*PASS*",
         ])
         assert " <- " not in result.stdout.str()
 
@@ -155,7 +155,7 @@
                 raise KeyboardInterrupt   # simulating the user
         """)
 
-        result = testdir.runpytest(*option.args)
+        result = testdir.runpytest(*option.args, no_reraise_ctrlc=True)
         result.stdout.fnmatch_lines([
             "    def test_foobar():",
             ">       assert 0",
@@ -178,7 +178,7 @@
                 pass
         """)
 
-        result = testdir.runpytest()
+        result = testdir.runpytest(no_reraise_ctrlc=True)
         assert result.ret == 2
         result.stdout.fnmatch_lines(['*KeyboardInterrupt*'])

Repository URL: https://bitbucket.org/pytest-dev/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