Skip to content

Commit 22d91b2

Browse files
committed
Black linting
1 parent 5c47b78 commit 22d91b2

16 files changed

+71
-42
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean clean-build clean-pyc clean-test
1+
.PHONY: clean clean-build clean-pyc clean-test lint
22

33
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
44

@@ -19,3 +19,7 @@ clean-test: ## remove test and coverage artifacts
1919
rm -fr .tox/
2020
rm -f .coverage
2121
rm -fr htmlcov/
22+
23+
lint: ## check style with flake8
24+
flake8 pytest_asyncio tests
25+
black --check --verbose pytest_asyncio tests

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pytest-asyncio: pytest support for asyncio
1010
.. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg
1111
:target: https://github.com/pytest-dev/pytest-asyncio
1212
:alt: Supported Python versions
13+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
14+
:target: https://github.com/ambv/black
1315

1416
pytest-asyncio is an Apache2 licensed library, written in Python, for testing
1517
asyncio code with pytest.

pytest_asyncio/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, fixturedef):
6262

6363
def add(self, name):
6464
"""Add fixture name to fixturedef
65-
and record in to_strip list (If not previously included)"""
65+
and record in to_strip list (If not previously included)"""
6666
if name in self.fixturedef.argnames:
6767
return
6868
self.fixturedef.argnames += (name,)

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ filterwarnings = error
1212
[metadata]
1313
# ensure LICENSE is included in wheel metadata
1414
license_file = LICENSE
15+
16+
[flake8]
17+
ignore = E203, E501, W503

tests/async_fixtures/test_async_fixtures_scope.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
module-scoped too.
44
"""
55
import asyncio
6+
67
import pytest
78

89

9-
@pytest.fixture(scope='module')
10+
@pytest.fixture(scope="module")
1011
def event_loop():
1112
"""A module-scoped event loop."""
1213
return asyncio.new_event_loop()
1314

1415

15-
@pytest.fixture(scope='module')
16+
@pytest.fixture(scope="module")
1617
async def async_fixture():
1718
await asyncio.sleep(0.1)
1819
return 1

tests/async_fixtures/test_async_fixtures_with_finalizer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import functools
3+
34
import pytest
45

56

@@ -8,11 +9,13 @@ async def test_module_with_event_loop_finalizer(port_with_event_loop_finalizer):
89
await asyncio.sleep(0.01)
910
assert port_with_event_loop_finalizer
1011

12+
1113
@pytest.mark.asyncio
1214
async def test_module_with_get_event_loop_finalizer(port_with_get_event_loop_finalizer):
1315
await asyncio.sleep(0.01)
1416
assert port_with_get_event_loop_finalizer
1517

18+
1619
@pytest.fixture(scope="module")
1720
def event_loop():
1821
"""Change event_loop fixture to module level."""
@@ -29,6 +32,7 @@ async def port_afinalizer():
2932
# await task using loop provided by event_loop fixture
3033
# RuntimeError is raised if task is created on a different loop
3134
await finalizer
35+
3236
event_loop.run_until_complete(port_afinalizer())
3337

3438
worker = asyncio.ensure_future(asyncio.sleep(0.2))
@@ -43,6 +47,7 @@ async def port_afinalizer():
4347
# await task using loop provided by asyncio.get_event_loop()
4448
# RuntimeError is raised if task is created on a different loop
4549
await finalizer
50+
4651
asyncio.get_event_loop().run_until_complete(port_afinalizer())
4752

4853
worker = asyncio.ensure_future(asyncio.sleep(0.2))

tests/async_fixtures/test_async_gen_fixtures.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import unittest.mock
32

43
import pytest
@@ -8,7 +7,7 @@
87
RETVAL = object()
98

109

11-
@pytest.fixture(scope='module')
10+
@pytest.fixture(scope="module")
1211
def mock():
1312
return unittest.mock.Mock(return_value=RETVAL)
1413

tests/async_fixtures/test_coroutine_fixtures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
END = object()
88
RETVAL = object()
99

10-
pytestmark = pytest.mark.skip(reason='@asyncio.coroutine fixtures are not supported yet')
10+
pytestmark = pytest.mark.skip(
11+
reason="@asyncio.coroutine fixtures are not supported yet"
12+
)
1113

1214

1315
@pytest.fixture

tests/async_fixtures/test_nested.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import asyncio
2+
23
import pytest
34

45

56
@pytest.fixture()
67
async def async_inner_fixture():
78
await asyncio.sleep(0.01)
8-
print('inner start')
9+
print("inner start")
910
yield True
10-
print('inner stop')
11+
print("inner stop")
1112

1213

1314
@pytest.fixture()
1415
async def async_fixture_outer(async_inner_fixture, event_loop):
1516
await asyncio.sleep(0.01)
16-
print('outer start')
17+
print("outer start")
1718
assert async_inner_fixture is True
1819
yield True
19-
print('outer stop')
20+
print("outer stop")
2021

2122

2223
@pytest.mark.asyncio
2324
async def test_async_fixture(async_fixture_outer):
2425
assert async_fixture_outer is True
25-
print('test_async_fixture')
26+
print("test_async_fixture")

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ async def just_a_sleep():
2222
assert counter == 2
2323

2424

25-
@pytest.fixture(scope='session', name='factory_involving_factories')
25+
@pytest.fixture(scope="session", name="factory_involving_factories")
2626
def factory_involving_factories_fixture(unused_tcp_port_factory):
2727
def factory():
2828
return unused_tcp_port_factory()
29+
2930
return factory

0 commit comments

Comments
 (0)