Skip to content

Commit 6a9b282

Browse files
authored
Merge pull request #192 from mgorny/py3-mock
Remove py2-specific dependencies and fix tests
2 parents 6665540 + 7004bc4 commit 6a9b282

File tree

7 files changed

+19
-28
lines changed

7 files changed

+19
-28
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Install Python
1414
uses: actions/setup-python@v2
1515
with:
16-
python-version: ${{ matrix.python_version }}
16+
python-version: ${{ matrix.python-version }}
1717
- name: Install dependencies
1818
run: python -m pip install tox
1919
- name: Run tests

readme_renderer/integration/distutils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import distutils.log
2121
from distutils.command.check import check as _check
2222
from distutils.core import Command
23-
import six
2423

2524
from ..rst import render
2625

@@ -35,7 +34,6 @@
3534
r'(?P<message>.*)', re.DOTALL | re.MULTILINE)
3635

3736

38-
@six.python_2_unicode_compatible
3937
class _WarningStream(object):
4038
def __init__(self):
4139
self.output = io.StringIO()

readme_renderer/markdown.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616
import re
1717
import warnings
1818

19+
from html.parser import unescape
20+
1921
import pygments
2022
import pygments.lexers
2123
import pygments.formatters
2224

23-
try:
24-
from six.moves.html_parser import unescape
25-
except ImportError: # Python 2
26-
from six.moves import html_parser
27-
28-
unescape = html_parser.HTMLParser().unescape
29-
3025
from .clean import clean
3126

3227
_EXTRA_WARNING = (

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"Programming Language :: Python :: Implementation :: CPython",
5656
"Programming Language :: Python :: Implementation :: PyPy",
5757
],
58-
install_requires=["bleach>=2.1.0", "docutils>=0.13.1", "Pygments>=2.5.1", "six"],
58+
install_requires=["bleach>=2.1.0", "docutils>=0.13.1", "Pygments>=2.5.1"],
5959
entry_points={
6060
"distutils.commands": ["check = readme_renderer.integration.distutils:Check"],
6161
},

tests/test_integration_distutils.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import distutils.dist
2+
import unittest.mock
23

3-
import mock
44
import pytest
55
import setuptools.dist
66

@@ -11,7 +11,7 @@ def test_valid_rst():
1111
dist = distutils.dist.Distribution(attrs=dict(
1212
long_description="Hello, I am some text."))
1313
checker = readme_renderer.integration.distutils.Check(dist)
14-
checker.warn = mock.Mock()
14+
checker.warn = unittest.mock.Mock()
1515

1616
checker.check_restructuredtext()
1717

@@ -22,14 +22,14 @@ def test_invalid_rst():
2222
dist = distutils.dist.Distribution(attrs=dict(
2323
long_description="Hello, I am some `totally borked< text."))
2424
checker = readme_renderer.integration.distutils.Check(dist)
25-
checker.warn = mock.Mock()
26-
checker.announce = mock.Mock()
25+
checker.warn = unittest.mock.Mock()
26+
checker.announce = unittest.mock.Mock()
2727

2828
checker.check_restructuredtext()
2929

3030
# Should warn once for the syntax error, and finally to warn that the
3131
# overall syntax is invalid
32-
checker.warn.assert_called_once_with(mock.ANY)
32+
checker.warn.assert_called_once_with(unittest.mock.ANY)
3333
message = checker.warn.call_args[0][0]
3434
assert 'invalid markup' in message
3535
assert 'line 1: Warning:' in message
@@ -47,14 +47,14 @@ def test_malicious_rst():
4747
dist = distutils.dist.Distribution(attrs=dict(
4848
long_description=description))
4949
checker = readme_renderer.integration.distutils.Check(dist)
50-
checker.warn = mock.Mock()
51-
checker.announce = mock.Mock()
50+
checker.warn = unittest.mock.Mock()
51+
checker.announce = unittest.mock.Mock()
5252

5353
checker.check_restructuredtext()
5454

5555
# Should warn once for the syntax error, and finally to warn that the
5656
# overall syntax is invalid
57-
checker.warn.assert_called_once_with(mock.ANY)
57+
checker.warn.assert_called_once_with(unittest.mock.ANY)
5858
message = checker.warn.call_args[0][0]
5959
assert 'directive disabled' in message
6060

@@ -68,7 +68,7 @@ def test_markdown():
6868
long_description="Hello, I am some text.",
6969
long_description_content_type="text/markdown"))
7070
checker = readme_renderer.integration.distutils.Check(dist)
71-
checker.warn = mock.Mock()
71+
checker.warn = unittest.mock.Mock()
7272

7373
checker.check_restructuredtext()
7474

@@ -79,21 +79,21 @@ def test_markdown():
7979
def test_invalid_missing():
8080
dist = distutils.dist.Distribution(attrs=dict())
8181
checker = readme_renderer.integration.distutils.Check(dist)
82-
checker.warn = mock.Mock()
82+
checker.warn = unittest.mock.Mock()
8383

8484
checker.check_restructuredtext()
8585

86-
checker.warn.assert_called_once_with(mock.ANY)
86+
checker.warn.assert_called_once_with(unittest.mock.ANY)
8787
assert 'missing' in checker.warn.call_args[0][0]
8888

8989

9090
def test_invalid_empty():
9191
dist = distutils.dist.Distribution(attrs=dict(
9292
long_description=""))
9393
checker = readme_renderer.integration.distutils.Check(dist)
94-
checker.warn = mock.Mock()
94+
checker.warn = unittest.mock.Mock()
9595

9696
checker.check_restructuredtext()
9797

98-
checker.warn.assert_called_once_with(mock.ANY)
98+
checker.warn.assert_called_once_with(unittest.mock.ANY)
9999
assert 'missing' in checker.warn.call_args[0][0]

tests/test_rst.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os.path
44

55
import pytest
6-
import six
76

87
from readme_renderer.rst import render
98

@@ -46,7 +45,7 @@ def test_rst_002():
4645

4746

4847
def test_rst_raw():
49-
warnings = six.StringIO()
48+
warnings = io.StringIO()
5049
assert render("""
5150
.. raw:: html
5251
<script>I am evil</script>

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ envlist = py36,py37,py38,py39,pep8,packaging,noextra
44
[testenv]
55
deps =
66
pytest
7-
mock
87
commands =
9-
py.test --strict {posargs}
8+
pytest --strict {posargs}
109
extras = md
1110

1211
[testenv:pep8]

0 commit comments

Comments
 (0)