From 0c2218a456372e64e8cf11afc8c65ce858670fc7 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 17 Mar 2022 15:54:59 +1100 Subject: [PATCH] Remove use of external mock As of Python 3.3, mock has been included in the standard library, and in fact, the test code makes use of that fact. However, the main plugin did not, so remove its usage, and drop it from setup.py. Also clean up the definition of StreamMock to boot. --- pytest_console_scripts.py | 11 ++--------- setup.py | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pytest_console_scripts.py b/pytest_console_scripts.py index 7dca21d..822b8d6 100644 --- a/pytest_console_scripts.py +++ b/pytest_console_scripts.py @@ -9,17 +9,10 @@ import sys import traceback -import mock +from unittest import mock import pytest -if sys.version_info.major == 2: - # We can't use io.StringIO for mocking stdout/stderr in Python 2 - # because printing byte strings to it triggers unicode errors and - # there's code in stdlib that does that (e.g. traceback module). - import StringIO - StreamMock = StringIO.StringIO -else: - StreamMock = io.StringIO +StreamMock = io.StringIO def pytest_addoption(parser): diff --git a/setup.py b/setup.py index 7bbbced..e0bdcf8 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def read(fname): long_description=read('README.md'), long_description_content_type='text/markdown', py_modules=['pytest_console_scripts'], - install_requires=['pytest>=4.0.0', 'mock>=2.0.0'], + install_requires=['pytest>=4.0.0'], python_requires='>=3.6', setup_requires=['setuptools-scm'], classifiers=[