Skip to content

Commit 68d7ad8

Browse files
committed
Run pre-commit in all files
1 parent 3a8ca0a commit 68d7ad8

File tree

11 files changed

+146
-136
lines changed

11 files changed

+146
-136
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- python: "3.9"
2222
tox_env: "py39"
2323
- python: "3.10"
24-
tox_env: "py310"
24+
tox_env: "py310"
2525

2626
steps:
2727
- uses: actions/checkout@v1
@@ -62,4 +62,4 @@ jobs:
6262
uses: pypa/gh-action-pypi-publish@master
6363
with:
6464
user: __token__
65-
password: ${{ secrets.pypi_token }}
65+
password: ${{ secrets.pypi_token }}

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ repos:
2222
hooks:
2323
- id: reorder-python-imports
2424
args: ['--application-directories=.:src']
25-

LICENSE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
copies of the Software, and to permit persons to whom the Software is
77
furnished to do so, subject to the following conditions:
8-
8+
99
The above copyright notice and this permission notice shall be included in all
1010
copies or substantial portions of the Software.
11-
11+
1212
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1313
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1414
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1515
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1616
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1717
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1818
SOFTWARE.
19-

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include CHANGELOG
2-
include LICENSE
2+
include LICENSE
33
include pyproject.toml
44
include README.txt
55
include setup.py

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This plugin **does not work on Windows** because there's no ``fork`` support.
2929
:target: https://github.com/ambv/black
3030

3131
.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest-forked/master.svg
32-
:target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest-forked/master
32+
:target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest-forked/master
3333

3434
Installation
3535
-----------------------

example/boxed.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ to run each test in a controlled subprocess. Here is a basic example::
1414
@pytest.mark.parametrize("arg", range(50))
1515
def test_func(arg):
1616
time.sleep(0.05) # each tests takes a while
17-
if arg % 19 == 0:
17+
if arg % 19 == 0:
1818
os.kill(os.getpid(), 15)
1919

2020
If you run this with::
@@ -24,9 +24,9 @@ If you run this with::
2424
platform linux2 -- Python 2.7.3 -- pytest-2.3.0.dev8
2525
plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov
2626
collecting ... collected 50 items
27-
27+
2828
test_module.py f..................f..................f...........
29-
29+
3030
================================= FAILURES =================================
3131
_______________________________ test_func[0] _______________________________
3232
/home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15
@@ -46,7 +46,7 @@ the xdist-provided parallelization feature to speed up your testing::
4646
plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov
4747
gw0 I / gw1 I / gw2 I
4848
gw0 [50] / gw1 [50] / gw2 [50]
49-
49+
5050
scheduling tests via LoadScheduling
5151
..f...............f..................f............
5252
================================= FAILURES =================================

setup.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@
33
setup(
44
name="pytest-forked",
55
use_scm_version=True,
6-
description='run tests in isolated forked subprocesses',
7-
long_description=open('README.rst').read(),
8-
long_description_content_type='text/x-rst',
9-
license='MIT',
10-
author='pytest-dev',
11-
author_email='pytest-dev@python.org',
12-
url='https://github.com/pytest-dev/pytest-forked',
13-
platforms=['linux', 'osx'],
14-
packages=['pytest_forked'],
15-
package_dir={'': 'src'},
6+
description="run tests in isolated forked subprocesses",
7+
long_description=open("README.rst").read(),
8+
long_description_content_type="text/x-rst",
9+
license="MIT",
10+
author="pytest-dev",
11+
author_email="pytest-dev@python.org",
12+
url="https://github.com/pytest-dev/pytest-forked",
13+
platforms=["linux", "osx"],
14+
packages=["pytest_forked"],
15+
package_dir={"": "src"},
1616
entry_points={
17-
'pytest11': [
18-
'pytest_forked = pytest_forked',
17+
"pytest11": [
18+
"pytest_forked = pytest_forked",
1919
],
2020
},
2121
zip_safe=False,
22-
install_requires=['py', 'pytest>=3.10'],
23-
setup_requires=['setuptools_scm'],
24-
python_requires='>=3.6',
22+
install_requires=["py", "pytest>=3.10"],
23+
setup_requires=["setuptools_scm"],
24+
python_requires=">=3.6",
2525
classifiers=[
26-
'Development Status :: 7 - Inactive',
27-
'Framework :: Pytest',
28-
'Intended Audience :: Developers',
29-
'License :: OSI Approved :: MIT License',
30-
'Operating System :: POSIX',
31-
'Operating System :: MacOS :: MacOS X',
32-
'Topic :: Software Development :: Testing',
33-
'Topic :: Software Development :: Quality Assurance',
34-
'Topic :: Utilities',
35-
'Programming Language :: Python',
36-
'Programming Language :: Python :: 3',
37-
'Programming Language :: Python :: 3.6',
38-
'Programming Language :: Python :: 3.7',
39-
'Programming Language :: Python :: 3.8',
40-
'Programming Language :: Python :: 3.9',
41-
'Programming Language :: Python :: 3.10',
42-
'Programming Language :: Python :: 3 :: Only',
26+
"Development Status :: 7 - Inactive",
27+
"Framework :: Pytest",
28+
"Intended Audience :: Developers",
29+
"License :: OSI Approved :: MIT License",
30+
"Operating System :: POSIX",
31+
"Operating System :: MacOS :: MacOS X",
32+
"Topic :: Software Development :: Testing",
33+
"Topic :: Software Development :: Quality Assurance",
34+
"Topic :: Utilities",
35+
"Programming Language :: Python",
36+
"Programming Language :: Python :: 3",
37+
"Programming Language :: Python :: 3.6",
38+
"Programming Language :: Python :: 3.7",
39+
"Programming Language :: Python :: 3.8",
40+
"Programming Language :: Python :: 3.9",
41+
"Programming Language :: Python :: 3.10",
42+
"Programming Language :: Python :: 3 :: Only",
4343
],
4444
)

src/pytest_forked/__init__.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
import warnings
33

44
import py
5-
# we know this bit is bad, but we cant help it with the current pytest setup
6-
from _pytest import runner
75
import pytest
6+
from _pytest import runner
7+
8+
# we know this bit is bad, but we cant help it with the current pytest setup
89

910

1011
# copied from xdist remote
1112
def serialize_report(rep):
1213
import py
14+
1315
d = rep.__dict__.copy()
14-
if hasattr(rep.longrepr, 'toterminal'):
15-
d['longrepr'] = str(rep.longrepr)
16+
if hasattr(rep.longrepr, "toterminal"):
17+
d["longrepr"] = str(rep.longrepr)
1618
else:
17-
d['longrepr'] = rep.longrepr
19+
d["longrepr"] = rep.longrepr
1820
for name in d:
1921
if isinstance(d[name], py.path.local):
2022
d[name] = str(d[name])
@@ -26,9 +28,12 @@ def serialize_report(rep):
2628
def pytest_addoption(parser):
2729
group = parser.getgroup("forked", "forked subprocess test execution")
2830
group.addoption(
29-
'--forked',
30-
action="store_true", dest="forked", default=False,
31-
help="box each test run in a separate process (unix)")
31+
"--forked",
32+
action="store_true",
33+
dest="forked",
34+
default=False,
35+
help="box each test run in a separate process (unix)",
36+
)
3237

3338

3439
def pytest_load_initial_conftests(early_config, parser, args):
@@ -54,6 +59,7 @@ def forked_run_report(item):
5459
# for now, we run setup/teardown in the subprocess
5560
# XXX optionally allow sharing of setup/teardown
5661
from _pytest.runner import runtestprotocol
62+
5763
EXITSTATUS_TESTEXIT = 4
5864
import marshal
5965

@@ -77,39 +83,43 @@ def runforked():
7783

7884
def report_process_crash(item, result):
7985
from _pytest._code import getfslineno
86+
8087
path, lineno = getfslineno(item)
81-
info = ("%s:%s: running the test CRASHED with signal %d" %
82-
(path, lineno, result.signal))
88+
info = "%s:%s: running the test CRASHED with signal %d" % (
89+
path,
90+
lineno,
91+
result.signal,
92+
)
8393
from _pytest import runner
94+
8495
# pytest >= 4.1
8596
has_from_call = getattr(runner.CallInfo, "from_call", None) is not None
8697
if has_from_call:
87-
call = runner.CallInfo.from_call(lambda: 0/0, "???")
98+
call = runner.CallInfo.from_call(lambda: 0 / 0, "???")
8899
else:
89-
call = runner.CallInfo(lambda: 0/0, "???")
100+
call = runner.CallInfo(lambda: 0 / 0, "???")
90101
call.excinfo = info
91102
rep = runner.pytest_runtest_makereport(item, call)
92103
if result.out:
93104
rep.sections.append(("captured stdout", result.out))
94105
if result.err:
95106
rep.sections.append(("captured stderr", result.err))
96107

97-
xfail_marker = item.get_closest_marker('xfail')
108+
xfail_marker = item.get_closest_marker("xfail")
98109
if not xfail_marker:
99110
return rep
100111

101112
rep.outcome = "skipped"
102113
rep.wasxfail = (
103114
"reason: {xfail_reason}; "
104-
"pytest-forked reason: {crash_info}".
105-
format(
106-
xfail_reason=xfail_marker.kwargs['reason'],
115+
"pytest-forked reason: {crash_info}".format(
116+
xfail_reason=xfail_marker.kwargs["reason"],
107117
crash_info=info,
108118
)
109119
)
110120
warnings.warn(
111-
'pytest-forked xfail support is incomplete at the moment and may '
112-
'output a misleading reason message',
121+
"pytest-forked xfail support is incomplete at the moment and may "
122+
"output a misleading reason message",
113123
RuntimeWarning,
114124
)
115125

testing/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
@pytest.fixture(autouse=True)
88
def _divert_atexit(request, monkeypatch):
99
import atexit
10+
1011
atexit_fns = []
1112

1213
def atexit_register(func, *args, **kwargs):

testing/test_boxed.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,70 @@
1-
import pytest
21
import os
32

4-
needsfork = pytest.mark.skipif(not hasattr(os, "fork"),
5-
reason="os.fork required")
3+
import pytest
4+
5+
needsfork = pytest.mark.skipif(not hasattr(os, "fork"), reason="os.fork required")
66

77

88
@needsfork
99
def test_functional_boxed(testdir):
10-
p1 = testdir.makepyfile("""
10+
p1 = testdir.makepyfile(
11+
"""
1112
import os
1213
def test_function():
1314
os.kill(os.getpid(), 15)
14-
""")
15+
"""
16+
)
1517
result = testdir.runpytest(p1, "--forked")
16-
result.stdout.fnmatch_lines([
17-
"*CRASHED*",
18-
"*1 failed*"
19-
])
18+
result.stdout.fnmatch_lines(["*CRASHED*", "*1 failed*"])
2019

2120

2221
@needsfork
2322
def test_functional_boxed_per_test(testdir):
24-
p1 = testdir.makepyfile("""
23+
p1 = testdir.makepyfile(
24+
"""
2525
import os
2626
import pytest
2727
2828
@pytest.mark.forked
2929
def test_function():
3030
os.kill(os.getpid(), 15)
31-
""")
31+
"""
32+
)
3233
result = testdir.runpytest(p1)
33-
result.stdout.fnmatch_lines([
34-
"*CRASHED*",
35-
"*1 failed*"
36-
])
34+
result.stdout.fnmatch_lines(["*CRASHED*", "*1 failed*"])
3735

3836

3937
@needsfork
40-
@pytest.mark.parametrize("capmode", [
41-
"no",
42-
pytest.param("sys", marks=pytest.mark.xfail(reason="capture cleanup needed")),
43-
pytest.param("fd", marks=pytest.mark.xfail(reason="capture cleanup needed"))])
38+
@pytest.mark.parametrize(
39+
"capmode",
40+
[
41+
"no",
42+
pytest.param("sys", marks=pytest.mark.xfail(reason="capture cleanup needed")),
43+
pytest.param("fd", marks=pytest.mark.xfail(reason="capture cleanup needed")),
44+
],
45+
)
4446
def test_functional_boxed_capturing(testdir, capmode):
45-
p1 = testdir.makepyfile("""
47+
p1 = testdir.makepyfile(
48+
"""
4649
import os
4750
import sys
4851
def test_function():
4952
sys.stdout.write("hello\\n")
5053
sys.stderr.write("world\\n")
5154
os.kill(os.getpid(), 15)
52-
""")
55+
"""
56+
)
5357
result = testdir.runpytest(p1, "--forked", "--capture=%s" % capmode)
54-
result.stdout.fnmatch_lines("""
58+
result.stdout.fnmatch_lines(
59+
"""
5560
*CRASHED*
5661
*stdout*
5762
hello
5863
*stderr*
5964
world
6065
*1 failed*
61-
""")
66+
"""
67+
)
6268

6369

6470
def test_is_not_boxed_by_default(testdir):

0 commit comments

Comments
 (0)