python-readme_renderer/remove-mock.patch
Dirk Mueller d49c45c547 Accepting request 880504 from home:bnavigator:branches:devel:languages:python
- Update to 29.0
  * Support cmarkgfm>=0.5.0 (#180)
  * Drop support for Python 2 and 3.5 (#188)
- Release 28.0
  * Support Python 3.9 (#176)
- Release 27.0
  * Add support for align attribute rendering Markdown headers
    (#173)
- Add remove-mock.patch and remove-six.patch to reduce outdated
  dependecies -- gh#pypa/readme_renderer#192
-

OBS-URL: https://build.opensuse.org/request/show/880504
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-readme_renderer?expand=0&rev=13
2021-03-22 22:13:51 +00:00

118 lines
4.1 KiB
Diff

From 091bcd67ada85e54b534a71fd63e5997120590a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Tue, 23 Feb 2021 08:32:32 +0100
Subject: [PATCH] Use built-in Python 3 unittest.mock module
Replace the use of external 'mock' package with the 'unittest.mock'
module provided by Python 3. Since Python 2 is no longer supported,
this eliminates an unnecessary dependency.
---
tests/test_integration_distutils.py | 26 +++++++++++++-------------
tox.ini | 1 -
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/tests/test_integration_distutils.py b/tests/test_integration_distutils.py
index 8118692..55a857e 100644
--- a/tests/test_integration_distutils.py
+++ b/tests/test_integration_distutils.py
@@ -1,6 +1,6 @@
import distutils.dist
+import unittest.mock
-import mock
import pytest
import setuptools.dist
@@ -11,7 +11,7 @@ def test_valid_rst():
dist = distutils.dist.Distribution(attrs=dict(
long_description="Hello, I am some text."))
checker = readme_renderer.integration.distutils.Check(dist)
- checker.warn = mock.Mock()
+ checker.warn = unittest.mock.Mock()
checker.check_restructuredtext()
@@ -22,14 +22,14 @@ def test_invalid_rst():
dist = distutils.dist.Distribution(attrs=dict(
long_description="Hello, I am some `totally borked< text."))
checker = readme_renderer.integration.distutils.Check(dist)
- checker.warn = mock.Mock()
- checker.announce = mock.Mock()
+ checker.warn = unittest.mock.Mock()
+ checker.announce = unittest.mock.Mock()
checker.check_restructuredtext()
# Should warn once for the syntax error, and finally to warn that the
# overall syntax is invalid
- checker.warn.assert_called_once_with(mock.ANY)
+ checker.warn.assert_called_once_with(unittest.mock.ANY)
message = checker.warn.call_args[0][0]
assert 'invalid markup' in message
assert 'line 1: Warning:' in message
@@ -47,14 +47,14 @@ def test_malicious_rst():
dist = distutils.dist.Distribution(attrs=dict(
long_description=description))
checker = readme_renderer.integration.distutils.Check(dist)
- checker.warn = mock.Mock()
- checker.announce = mock.Mock()
+ checker.warn = unittest.mock.Mock()
+ checker.announce = unittest.mock.Mock()
checker.check_restructuredtext()
# Should warn once for the syntax error, and finally to warn that the
# overall syntax is invalid
- checker.warn.assert_called_once_with(mock.ANY)
+ checker.warn.assert_called_once_with(unittest.mock.ANY)
message = checker.warn.call_args[0][0]
assert 'directive disabled' in message
@@ -68,7 +68,7 @@ def test_markdown():
long_description="Hello, I am some text.",
long_description_content_type="text/markdown"))
checker = readme_renderer.integration.distutils.Check(dist)
- checker.warn = mock.Mock()
+ checker.warn = unittest.mock.Mock()
checker.check_restructuredtext()
@@ -79,11 +79,11 @@ def test_markdown():
def test_invalid_missing():
dist = distutils.dist.Distribution(attrs=dict())
checker = readme_renderer.integration.distutils.Check(dist)
- checker.warn = mock.Mock()
+ checker.warn = unittest.mock.Mock()
checker.check_restructuredtext()
- checker.warn.assert_called_once_with(mock.ANY)
+ checker.warn.assert_called_once_with(unittest.mock.ANY)
assert 'missing' in checker.warn.call_args[0][0]
@@ -91,9 +91,9 @@ def test_invalid_empty():
dist = distutils.dist.Distribution(attrs=dict(
long_description=""))
checker = readme_renderer.integration.distutils.Check(dist)
- checker.warn = mock.Mock()
+ checker.warn = unittest.mock.Mock()
checker.check_restructuredtext()
- checker.warn.assert_called_once_with(mock.ANY)
+ checker.warn.assert_called_once_with(unittest.mock.ANY)
assert 'missing' in checker.warn.call_args[0][0]
diff --git a/tox.ini b/tox.ini
index 70fdc66..5edb19f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,6 @@ envlist = py36,py37,py38,py39,pep8,packaging,noextra
[testenv]
deps =
pytest
- mock
commands =
py.test --strict {posargs}
extras = md