forked from pool/python-pytest-spec
d48b71a66a
* Added support for multiline docstrings * Added logic to use docstring_summary instead of test name * Added logic to ignore some tests from spec output * Changed indicator for skipped tests * Improve formatting for functions * Changed actions to test against python and pytest versions * Added tests to sdist - Add patch remove-mock.patch: * Use stdlib unittest.mock - Correct filelist, and do not install test directory under sitelib. - Remove mock from {Build,}Requires, add six. - Drop seperate LICENSE, it's now included. - Actually run the testsuite. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-spec?expand=0&rev=10
76 lines
2.0 KiB
Diff
76 lines
2.0 KiB
Diff
From 811abee39d7fae705c0b9b2e0598bc0fd4f96c36 Mon Sep 17 00:00:00 2001
|
|
From: Steve Kowalik <steven@wedontsleep.org>
|
|
Date: Wed, 23 Mar 2022 18:00:06 +1100
|
|
Subject: [PATCH] Also support stdlib mock
|
|
|
|
Python >=3.3 has included mock in the standard library, so try and
|
|
import that before falling back to the external mock.
|
|
---
|
|
pyproject.toml | 2 +-
|
|
test/test_patch.py | 5 ++++-
|
|
test/test_plugin.py | 5 ++++-
|
|
test/test_replacer.py | 5 ++++-
|
|
4 files changed, 13 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/pyproject.toml b/pyproject.toml
|
|
index ca689f9..448d9ad 100644
|
|
--- a/pyproject.toml
|
|
+++ b/pyproject.toml
|
|
@@ -33,7 +33,7 @@ include = ["LICENSE.txt"]
|
|
six = "*"
|
|
|
|
[tool.poetry.dev-dependencies]
|
|
-mock = ">1.0.1"
|
|
+mock = { version = ">1.0.1", python = "~2.7" }
|
|
pytest = "*"
|
|
pytest-describe = "*"
|
|
pytest-flake8 = "*"
|
|
diff --git a/test/test_patch.py b/test/test_patch.py
|
|
index 05ec407..bf9fbcf 100644
|
|
--- a/test/test_patch.py
|
|
+++ b/test/test_patch.py
|
|
@@ -4,7 +4,10 @@
|
|
"""
|
|
import unittest
|
|
|
|
-from mock import Mock, call
|
|
+try:
|
|
+ from unittest.mock import Mock, call
|
|
+except ImportError:
|
|
+ from mock import Mock, call
|
|
|
|
import pytest_spec
|
|
from pytest_spec.patch import pytest_runtest_logstart, pytest_runtest_logreport
|
|
diff --git a/test/test_plugin.py b/test/test_plugin.py
|
|
index 2bcaec4..ca95800 100755
|
|
--- a/test/test_plugin.py
|
|
+++ b/test/test_plugin.py
|
|
@@ -4,7 +4,10 @@
|
|
"""
|
|
import unittest
|
|
|
|
-from mock import Mock, call, patch
|
|
+try:
|
|
+ from unittest.mock import Mock, call, patch
|
|
+except ImportError:
|
|
+ from mock import Mock, call, patch
|
|
from pytest_spec.plugin import pytest_addoption, pytest_configure
|
|
|
|
|
|
diff --git a/test/test_replacer.py b/test/test_replacer.py
|
|
index 9526bc1..a805f83 100644
|
|
--- a/test/test_replacer.py
|
|
+++ b/test/test_replacer.py
|
|
@@ -4,7 +4,10 @@
|
|
"""
|
|
import unittest
|
|
|
|
-from mock import patch
|
|
+try:
|
|
+ from unittest.mock import patch
|
|
+except ImportError:
|
|
+ from mock import patch
|
|
from pytest_spec.replacer import logstart_replacer, report_replacer
|
|
|
|
|