Hello community,

here is the log from the commit of package python-pytest-mock for 
openSUSE:Factory checked in at 2019-12-11 11:59:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-mock (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-mock.new.4691 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-mock"

Wed Dec 11 11:59:52 2019 rev:16 rq:753969 version:1.12.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pytest-mock/python-pytest-mock.changes    
2019-11-22 10:25:45.769267559 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-mock.new.4691/python-pytest-mock.changes
  2019-12-11 12:00:14.280863697 +0100
@@ -1,0 +2,9 @@
+Wed Dec  4 12:04:01 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 1.12.1:
+  * Fix error if mocker.patch is used in code where the source file
+    is not available, for example stale .pyc files
+  * Now all patch functions also raise a ValueError when used as a
+    context-manager
+
+-------------------------------------------------------------------

Old:
----
  pytest-mock-1.11.2.tar.gz

New:
----
  pytest-mock-1.12.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pytest-mock.spec ++++++
--- /var/tmp/diff_new_pack.kWpMRk/_old  2019-12-11 12:00:16.744862660 +0100
+++ /var/tmp/diff_new_pack.kWpMRk/_new  2019-12-11 12:00:16.756862655 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pytest-mock
 #
-# Copyright (c) 2019 SUSE LLC.
+# Copyright (c) 2019 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -20,11 +20,10 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %bcond_without python2
 Name:           python-pytest-mock
-Version:        1.11.2
+Version:        1.12.1
 Release:        0
 Summary:        Thin-wrapper around the mock package for easier use with pytest
 License:        MIT
-Group:          Development/Languages/Python
 URL:            https://github.com/pytest-dev/pytest-mock
 Source:         
https://files.pythonhosted.org/packages/source/p/pytest-mock/pytest-mock-%{version}.tar.gz
 BuildRequires:  %{python_module pytest}

++++++ pytest-mock-1.11.2.tar.gz -> pytest-mock-1.12.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/.github/workflows/main.yml 
new/pytest-mock-1.12.1/.github/workflows/main.yml
--- old/pytest-mock-1.11.2/.github/workflows/main.yml   2019-10-23 
18:36:06.000000000 +0200
+++ new/pytest-mock-1.12.1/.github/workflows/main.yml   2019-11-20 
23:07:32.000000000 +0100
@@ -10,7 +10,7 @@
     strategy:
       fail-fast: false
       matrix:
-        python: ["2.7", "3.5", "3.6", "3.7"]
+        python: ["2.7", "3.5", "3.6", "3.7", "3.8"]
         os: [ubuntu-latest, windows-latest]
         include:
           - python: "2.7"
@@ -21,6 +21,8 @@
             tox_env: "py36"
           - python: "3.7"
             tox_env: "py37"
+          - python: "3.8"
+            tox_env: "py38"
 
     steps:
     - uses: actions/checkout@v1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/.pre-commit-config.yaml 
new/pytest-mock-1.12.1/.pre-commit-config.yaml
--- old/pytest-mock-1.11.2/.pre-commit-config.yaml      2019-10-23 
18:36:06.000000000 +0200
+++ new/pytest-mock-1.12.1/.pre-commit-config.yaml      2019-11-20 
23:07:32.000000000 +0100
@@ -19,4 +19,3 @@
         files: ^(CHANGELOG.rst|README.rst|HOWTORELEASE.rst|changelog/.*)$
         language: python
         additional_dependencies: [pygments, restructuredtext_lint]
-        python_version: python3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/CHANGELOG.rst 
new/pytest-mock-1.12.1/CHANGELOG.rst
--- old/pytest-mock-1.11.2/CHANGELOG.rst        2019-10-23 18:36:06.000000000 
+0200
+++ new/pytest-mock-1.12.1/CHANGELOG.rst        2019-11-20 23:07:32.000000000 
+0100
@@ -1,3 +1,20 @@
+1.12.1 (2019-11-20)
+-------------------
+
+* Fix error if ``mocker.patch`` is used in code where the source file
+  is not available, for example stale ``.pyc`` files (`#169`_).
+
+.. _#169: 
https://github.com/pytest-dev/pytest-mock/issues/169#issuecomment-555729265
+
+1.12.0 (2019-11-19)
+-------------------
+
+* Now all patch functions also raise a ``ValueError`` when used
+  as a context-manager. Thanks `@AlexGascon`_ for the PR (`#168`_).
+
+.. _@AlexGascon: https://github.com/AlexGascon
+.. _#168: https://github.com/pytest-dev/pytest-mock/pull/168
+
 1.11.2 (2019-10-19)
 -------------------
 
@@ -5,7 +22,7 @@
   if there is no pytest introspection (`#154`_).
   Thanks `@The-Compiler`_ for the report.
 
-* ``mocker`` now raises a ``TypeError`` when used as a context-manager.
+* ``mocker`` now raises a ``ValueError`` when used as a context-manager.
   Thanks `@binarymason`_ for the PR (`#165`_).
 
 .. _#154: https://github.com/pytest-dev/pytest-mock/issues/154
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/PKG-INFO 
new/pytest-mock-1.12.1/PKG-INFO
--- old/pytest-mock-1.11.2/PKG-INFO     2019-10-23 18:36:17.000000000 +0200
+++ new/pytest-mock-1.12.1/PKG-INFO     2019-11-20 23:07:44.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-mock
-Version: 1.11.2
+Version: 1.12.1
 Summary: Thin-wrapper around the mock package for easier use with py.test
 Home-page: https://github.com/pytest-dev/pytest-mock/
 Author: Bruno Oliveira
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/src/pytest_mock/_version.py 
new/pytest-mock-1.12.1/src/pytest_mock/_version.py
--- old/pytest-mock-1.11.2/src/pytest_mock/_version.py  2019-10-23 
18:36:16.000000000 +0200
+++ new/pytest-mock-1.12.1/src/pytest_mock/_version.py  2019-11-20 
23:07:42.000000000 +0100
@@ -1,4 +1,4 @@
 # coding: utf-8
 # file generated by setuptools_scm
 # don't change, don't track in version control
-version = '1.11.2'
+version = '1.12.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/src/pytest_mock/plugin.py 
new/pytest-mock-1.12.1/src/pytest_mock/plugin.py
--- old/pytest-mock-1.11.2/src/pytest_mock/plugin.py    2019-10-23 
18:36:06.000000000 +0200
+++ new/pytest-mock-1.12.1/src/pytest_mock/plugin.py    2019-11-20 
23:07:32.000000000 +0100
@@ -147,6 +147,7 @@
             module, registering the patch to stop it later and returns the
             mock object resulting from the mock call.
             """
+            self._enforce_no_with_context(inspect.stack())
             p = mock_func(*args, **kwargs)
             mocked = p.start()
             self._patches.append(p)
@@ -154,16 +155,14 @@
                 self._mocks.append(mocked)
             return mocked
 
-        def object(self, *args, **kwargs):
-            """API to mock.patch.object"""
-            self._enforce_no_with_context(inspect.stack())
-            return self._start_patch(self.mock_module.patch.object, *args, 
**kwargs)
-
         def _enforce_no_with_context(self, stack):
             """raises a ValueError if mocker is used in a with context"""
-            caller = stack[1]
+            caller = stack[2]
             frame = caller[0]
             info = inspect.getframeinfo(frame)
+            if info.code_context is None:
+                # no source code available (#169)
+                return
             code_context = " ".join(info.code_context).strip()
 
             if code_context.startswith("with mocker."):
@@ -172,6 +171,10 @@
                     
"https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager";
                 )
 
+        def object(self, *args, **kwargs):
+            """API to mock.patch.object"""
+            return self._start_patch(self.mock_module.patch.object, *args, 
**kwargs)
+
         def multiple(self, *args, **kwargs):
             """API to mock.patch.multiple"""
             return self._start_patch(self.mock_module.patch.multiple, *args, 
**kwargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/src/pytest_mock.egg-info/PKG-INFO 
new/pytest-mock-1.12.1/src/pytest_mock.egg-info/PKG-INFO
--- old/pytest-mock-1.11.2/src/pytest_mock.egg-info/PKG-INFO    2019-10-23 
18:36:16.000000000 +0200
+++ new/pytest-mock-1.12.1/src/pytest_mock.egg-info/PKG-INFO    2019-11-20 
23:07:42.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-mock
-Version: 1.11.2
+Version: 1.12.1
 Summary: Thin-wrapper around the mock package for easier use with py.test
 Home-page: https://github.com/pytest-dev/pytest-mock/
 Author: Bruno Oliveira
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/tests/test_pytest_mock.py 
new/pytest-mock-1.12.1/tests/test_pytest_mock.py
--- old/pytest-mock-1.11.2/tests/test_pytest_mock.py    2019-10-23 
18:36:06.000000000 +0200
+++ new/pytest-mock-1.12.1/tests/test_pytest_mock.py    2019-11-20 
23:07:32.000000000 +0100
@@ -723,7 +723,7 @@
     assert "RuntimeError" not in result.stderr.str()
 
 
-def test_abort_context_manager(mocker):
+def test_abort_patch_object_context_manager(mocker):
     class A(object):
         def doIt(self):
             return False
@@ -740,3 +740,54 @@
     )
 
     assert str(excinfo.value) == expected_error_msg
+
+
+def test_abort_patch_context_manager(mocker):
+    with pytest.raises(ValueError) as excinfo:
+        with mocker.patch("some_package"):
+            pass
+
+    expected_error_msg = (
+        "Using mocker in a with context is not supported. "
+        
"https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager";
+    )
+
+    assert str(excinfo.value) == expected_error_msg
+
+
+def test_abort_patch_context_manager_with_stale_pyc(testdir):
+    """Ensure we don't trigger an error in case the frame where mocker.patch 
is being
+    used doesn't have a 'context' (#169)"""
+    import compileall
+
+    py_fn = testdir.makepyfile(
+        c="""
+        class C:
+            x = 1
+
+        def check(mocker):
+            mocker.patch.object(C, "x", 2)
+            assert C.x == 2
+    """
+    )
+    testdir.syspathinsert()
+
+    testdir.makepyfile(
+        """
+        from c import check
+        def test_foo(mocker):
+            check(mocker)
+    """
+    )
+    result = testdir.runpytest()
+    result.stdout.fnmatch_lines("* 1 passed *")
+
+    kwargs = {"legacy": True} if sys.version_info[0] >= 3 else {}
+    assert compileall.compile_file(str(py_fn), **kwargs)
+
+    pyc_fn = str(py_fn) + "c"
+    assert os.path.isfile(pyc_fn)
+
+    py_fn.remove()
+    result = testdir.runpytest()
+    result.stdout.fnmatch_lines("* 1 passed *")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.11.2/tox.ini 
new/pytest-mock-1.12.1/tox.ini
--- old/pytest-mock-1.11.2/tox.ini      2019-10-23 18:36:06.000000000 +0200
+++ new/pytest-mock-1.12.1/tox.ini      2019-11-20 23:07:32.000000000 +0100
@@ -1,5 +1,5 @@
 [tox]
-envlist = py{27,34,35,36,37}, linting, norewrite
+envlist = py{27,34,35,36,37,38}, linting, norewrite
 
 [testenv]
 passenv = USER USERNAME


Reply via email to