2019-02-06 22:25:51 +01:00
|
|
|
From: Antonio Larrosa <alarrosa@suse.com>
|
|
|
|
Subject: Fix mock.patch with python3.4
|
|
|
|
|
|
|
|
In python 3.5, mock.patch uses create=True automatically if you are patching
|
|
|
|
builtins in a module, but in python 3.4 the argument is still needed.
|
2021-11-10 15:27:52 +01:00
|
|
|
diff --git a/tests/unit/test_base_formatter.py b/tests/unit/test_base_formatter.py
|
|
|
|
index d096457..47e74a6 100644
|
2020-05-04 22:33:15 +02:00
|
|
|
--- a/tests/unit/test_base_formatter.py
|
|
|
|
+++ b/tests/unit/test_base_formatter.py
|
2021-11-10 15:27:52 +01:00
|
|
|
@@ -23,7 +23,7 @@ def test_start(filename):
|
2019-02-06 22:25:51 +01:00
|
|
|
"""Verify we open a new file in the start method."""
|
|
|
|
mock_open = mock.mock_open()
|
|
|
|
formatter = base.BaseFormatter(options(output_file=filename))
|
2021-11-10 15:27:52 +01:00
|
|
|
- with mock.patch("flake8.formatting.base.open", mock_open):
|
|
|
|
+ with mock.patch("flake8.formatting.base.open", mock_open, create=True):
|
2019-02-06 22:25:51 +01:00
|
|
|
formatter.start()
|
|
|
|
|
|
|
|
if filename is None:
|
2021-11-10 15:27:52 +01:00
|
|
|
diff --git a/tests/unit/test_debug.py b/tests/unit/test_debug.py
|
|
|
|
index 2da4bf8..074b409 100644
|
|
|
|
--- a/tests/unit/test_debug.py
|
|
|
|
+++ b/tests/unit/test_debug.py
|
|
|
|
@@ -95,7 +95,7 @@ def test_information(system, pyversion, pyimpl):
|
|
|
|
system.assert_called_once_with()
|
2019-02-06 22:25:51 +01:00
|
|
|
|
|
|
|
|
2021-11-10 15:27:52 +01:00
|
|
|
-@mock.patch("flake8.main.debug.print")
|
|
|
|
+@mock.patch("flake8.main.debug.print", create=True)
|
|
|
|
@mock.patch("flake8.main.debug.information", return_value={})
|
|
|
|
@mock.patch("json.dumps", return_value="{}")
|
|
|
|
def test_print_information_no_plugins(dumps, information, print_mock):
|
|
|
|
@@ -112,7 +112,7 @@ def test_print_information_no_plugins(dumps, information, print_mock):
|
|
|
|
assert print_mock.called is False
|
2019-02-06 22:25:51 +01:00
|
|
|
|
2021-11-10 15:27:52 +01:00
|
|
|
|
|
|
|
-@mock.patch("flake8.main.debug.print")
|
|
|
|
+@mock.patch("flake8.main.debug.print", create=True)
|
|
|
|
@mock.patch("flake8.main.debug.information", return_value={})
|
|
|
|
@mock.patch("json.dumps", return_value="{}")
|
|
|
|
def test_print_information(dumps, information, print_mock):
|