Skip to content

Commit 8d5714d

Browse files
committed
Initial commit with two functions.
1 parent 2ae5eee commit 8d5714d

File tree

8 files changed

+61
-7
lines changed

8 files changed

+61
-7
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.2
2+
current_version = 0.0.0
33
commit = True
44
tag = True
55

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ testing-tox
5959
.. |language| image:: https://img.shields.io/github/languages/top/python-coincidence/testing-tox
6060
:alt: GitHub top language
6161

62-
.. |commits-since| image:: https://img.shields.io/github/commits-since/python-coincidence/testing-tox/v0.2.2
62+
.. |commits-since| image:: https://img.shields.io/github/commits-since/python-coincidence/testing-tox/v0.0.0
6363
:target: https://github.com/python-coincidence/testing-tox/pulse
6464
:alt: GitHub commits since tagged version
6565

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2021 Dominic Davis-Foster <dominic@davis-foster.co.uk>
2727
"""
2828

29-
__version__ = "0.2.2"
29+
__version__ = "0.0.0"
3030
repo_root = pathlib.Path(__file__).parent
3131
install_requires = (repo_root / "requirements.txt").read_text(encoding="utf-8").split('\n')
3232
extras_require = {}

formate.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ lines_between_types = 0
3131
use_parentheses = true
3232
remove_redundant_aliases = true
3333
default_section = "THIRDPARTY"
34-
known_third_party = []
34+
known_third_party = [ "domdf_python_tools", "pytest", "tox",]
3535
known_first_party = "testing_tox"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "whey"
44

55
[project]
66
name = "testing-tox"
7-
version = "0.2.2"
7+
version = "0.0.0"
88
description = "Handy functions for testing tox plugins."
99
readme = "README.rst"
1010
keywords = [ "tox",]

repo_helper.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: 'Dominic Davis-Foster'
66
email: 'dominic@davis-foster.co.uk'
77
username: 'python-coincidence'
88
assignee: 'domdfcoding'
9-
version: '0.2.2'
9+
version: '0.0.0'
1010
license: 'MIT'
1111
short_desc: 'Handy functions for testing tox plugins.'
1212

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
domdf-python-tools>=2.8.1
2+
pytest>=6.2.2
3+
tox>=3.23.0

testing_tox/__init__.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,59 @@
2626
# OR OTHER DEALINGS IN THE SOFTWARE.
2727
#
2828

29+
# stdlib
30+
import re
31+
import sys
32+
from typing import Iterable
33+
34+
# 3rd party
35+
import pytest
36+
import tox.reporter # type: ignore
37+
from domdf_python_tools.paths import PathPlus, in_directory
38+
2939
__author__: str = "Dominic Davis-Foster"
3040
__copyright__: str = "2021 Dominic Davis-Foster"
3141
__license__: str = "MIT License"
32-
__version__: str = "0.2.2"
42+
__version__: str = "0.0.0"
3343
__email__: str = "dominic@davis-foster.co.uk"
44+
45+
__all__ = ["prepare_stdout", "run_tox"]
46+
47+
48+
def run_tox(args: Iterable[str], workdir: PathPlus):
49+
"""
50+
Run ``tox`` in ``workdir`` with the given arguments.
51+
52+
:param args:
53+
:param workdir:
54+
"""
55+
56+
tox.reporter._INSTANCE.tw._file = sys.stdout
57+
58+
with pytest.raises(SystemExit), in_directory(workdir):
59+
tox.cmdline(list(args))
60+
61+
62+
def prepare_stdout(stdout: str, toxinidir: PathPlus):
63+
"""
64+
Given the content of ``sys.stdout`` captured from a run of ``tox``,
65+
prepare the output for regression tests.
66+
67+
This entails replacing the path ``toxindir`` with ``...``,
68+
and removing deprecation warnings generated by ``packaging``.
69+
70+
:param stdout:
71+
:param toxinidir:
72+
""" # noqa: D400
73+
74+
stdout = stdout.replace(str(toxinidir), "...")
75+
stdout = re.sub(
76+
r"\.\.\.[\\/]\.tox[\\/].*[\\/]lib[\\/]python3\.\d[\\/]site-packages[\\/]pip[\\/]"
77+
r"_vendor[\\/]packaging[\\/]version\.py:\d*: "
78+
r"DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed "
79+
r"in the next major release, {2}(warnings\.warn\(|DeprecationWarning,)",
80+
'',
81+
stdout,
82+
)
83+
84+
return stdout

0 commit comments

Comments
 (0)