8d93e13
From 91b09d5b376cfb8afd4b6af5b407f57aa42011c7 Mon Sep 17 00:00:00 2001
8d93e13
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
8d93e13
Date: Mon, 20 Jul 2020 13:18:23 +0200
8d93e13
Subject: [PATCH] Tests: Add a value to mocked entry_points, so pytest 6+ can
8d93e13
 log it
8d93e13
8d93e13
Pytest 6.0.0rc1 attempts to log a repr of our mocked entry_point,
8d93e13
but it fails, becasue the repr metohod expects a valua attribute:
8d93e13
8d93e13
Reproducer:
8d93e13
8d93e13
    $ tox -e py38 --force-dep 'pytest==6.0.0rc1'
8d93e13
    ...
8d93e13
    Traceback (most recent call last):
8d93e13
      File "/usr/lib/python3.8/logging/__init__.py", line 1081, in emit
8d93e13
        msg = self.format(record)
8d93e13
      File "/usr/lib/python3.8/logging/__init__.py", line 925, in format
8d93e13
        return fmt.format(record)
8d93e13
      File "/usr/lib/python3.8/logging/__init__.py", line 664, in format
8d93e13
        record.message = record.getMessage()
8d93e13
      File "/usr/lib/python3.8/logging/__init__.py", line 369, in getMessage
8d93e13
        msg = msg % self.args
8d93e13
      File "/tmp/flake8/.tox/py38/lib/python3.8/site-packages/flake8/plugins/manager.py", line 44, in __repr__
8d93e13
        self.name, self.entry_point.value
8d93e13
      File "/tmp/flake8/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 632, in __getattr__
8d93e13
        raise AttributeError("Mock object has no attribute %r" % name)
8d93e13
    AttributeError: Mock object has no attribute 'value'
8d93e13
---
8d93e13
 tests/integration/test_checker.py | 1 +
8d93e13
 1 file changed, 1 insertion(+)
8d93e13
8d93e13
diff --git a/tests/integration/test_checker.py b/tests/integration/test_checker.py
8d93e13
index eaab5c3..0acdb6e 100644
8d93e13
--- a/tests/integration/test_checker.py
8d93e13
+++ b/tests/integration/test_checker.py
8d93e13
@@ -100,6 +100,7 @@ def mock_file_checker_with_plugin(plugin_target):
8d93e13
     entry_point = mock.Mock(spec=['load'])
8d93e13
     entry_point.name = plugin_target.name
8d93e13
     entry_point.load.return_value = plugin_target
8d93e13
+    entry_point.value = 'mocked:value'
8d93e13
 
8d93e13
     # Load the checker plugins using the entry point mock
8d93e13
     with mock.patch.object(
8d93e13
-- 
8d93e13
GitLab
8d93e13