Skip to content

Commit e5f114d

Browse files
committed
Fix formatting using black
1 parent a0d1728 commit e5f114d

File tree

3 files changed

+256
-249
lines changed

3 files changed

+256
-249
lines changed

pytest_twisted.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class _instances:
2323

2424

2525
def pytest_namespace():
26-
return {'inlineCallbacks': inlineCallbacks, 'blockon': blockon}
26+
return {"inlineCallbacks": inlineCallbacks, "blockon": blockon}
2727

2828

2929
def blockon(d):
@@ -35,8 +35,9 @@ def blockon(d):
3535

3636
def blockon_default(d):
3737
current = greenlet.getcurrent()
38-
assert current is not _instances.gr_twisted, \
39-
'blockon cannot be called from the twisted greenlet'
38+
assert (
39+
current is not _instances.gr_twisted
40+
), "blockon cannot be called from the twisted greenlet"
4041
result = []
4142

4243
def cb(r):
@@ -47,7 +48,7 @@ def cb(r):
4748
d.addCallbacks(cb, cb)
4849
if not result:
4950
_result = _instances.gr_twisted.switch()
50-
assert _result is result, 'illegal switch in blockon'
51+
assert _result is result, "illegal switch in blockon"
5152

5253
if isinstance(result[0], failure.Failure):
5354
result[0].raiseException()
@@ -88,7 +89,7 @@ def _pytest_pyfunc_call(pyfuncitem):
8889
return testfunction(*pyfuncitem._args)
8990
else:
9091
funcargs = pyfuncitem.funcargs
91-
if hasattr(pyfuncitem, '_fixtureinfo'):
92+
if hasattr(pyfuncitem, "_fixtureinfo"):
9293
testargs = {}
9394
for arg in pyfuncitem._fixtureinfo.argnames:
9495
testargs[arg] = funcargs[arg]
@@ -100,7 +101,7 @@ def _pytest_pyfunc_call(pyfuncitem):
100101
def pytest_pyfunc_call(pyfuncitem):
101102
if _instances.gr_twisted is not None:
102103
if _instances.gr_twisted.dead:
103-
raise RuntimeError('twisted reactor has stopped')
104+
raise RuntimeError("twisted reactor has stopped")
104105

105106
def in_reactor(d, f, *args):
106107
return defer.maybeDeferred(f, *args).chainDeferred(d)
@@ -112,14 +113,14 @@ def in_reactor(d, f, *args):
112113
blockon_default(d)
113114
else:
114115
if not _instances.reactor.running:
115-
raise RuntimeError('twisted reactor is not running')
116+
raise RuntimeError("twisted reactor is not running")
116117
blockingCallFromThread(
117118
_instances.reactor, _pytest_pyfunc_call, pyfuncitem
118119
)
119120
return True
120121

121122

122-
@pytest.fixture(scope='session', autouse=True)
123+
@pytest.fixture(scope="session", autouse=True)
123124
def twisted_greenlet(request):
124125
request.addfinalizer(stop_twisted_greenlet)
125126
return _instances.gr_twisted
@@ -130,32 +131,27 @@ def init_default_reactor():
130131

131132
module = inspect.getmodule(twisted.internet.default.install)
132133

133-
module_name = module.__name__.split('.')[-1]
134-
reactor_type_name, = (
135-
x
136-
for x in dir(module)
137-
if x.lower() == module_name
138-
)
134+
module_name = module.__name__.split(".")[-1]
135+
reactor_type_name, = (x for x in dir(module) if x.lower() == module_name)
139136
reactor_type = getattr(module, reactor_type_name)
140137

141138
_install_reactor(
142139
reactor_installer=twisted.internet.default.install,
143-
reactor_type=reactor_type
140+
reactor_type=reactor_type,
144141
)
145142

146143

147144
def init_qt5_reactor():
148145
import qt5reactor
149146

150147
_install_reactor(
151-
reactor_installer=qt5reactor.install,
152-
reactor_type=qt5reactor.QtReactor
148+
reactor_installer=qt5reactor.install, reactor_type=qt5reactor.QtReactor
153149
)
154150

155151

156152
reactor_installers = {
157-
'default': init_default_reactor,
158-
'qt5reactor': init_qt5_reactor
153+
"default": init_default_reactor,
154+
"qt5reactor": init_qt5_reactor,
159155
}
160156

161157

@@ -164,26 +160,28 @@ def _install_reactor(reactor_installer, reactor_type):
164160
reactor_installer()
165161
except error.ReactorAlreadyInstalledError:
166162
import twisted.internet.reactor
163+
167164
if not isinstance(twisted.internet.reactor, reactor_type):
168165
raise WrongReactorAlreadyInstalledError(
169-
'expected {} but found {}'.format(
170-
reactor_type,
171-
type(twisted.internet.reactor)
166+
"expected {} but found {}".format(
167+
reactor_type, type(twisted.internet.reactor)
172168
)
173169
)
170+
174171
import twisted.internet.reactor
172+
175173
_instances.reactor = twisted.internet.reactor
176174
init_twisted_greenlet()
177175

178176

179177
def pytest_addoption(parser):
180-
group = parser.getgroup('twisted')
178+
group = parser.getgroup("twisted")
181179
group.addoption(
182-
'--reactor',
183-
default='default',
184-
choices=tuple(reactor_installers.keys())
180+
"--reactor",
181+
default="default",
182+
choices=tuple(reactor_installers.keys()),
185183
)
186184

187185

188186
def pytest_configure(config):
189-
reactor_installers[config.getoption('reactor')]()
187+
reactor_installers[config.getoption("reactor")]()

setup.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
#!/usr/bin/env python
2-
31
from setuptools import setup
42

3+
with open("README.rst") as f:
4+
long_description = f.read()
5+
56
setup(
6-
name='pytest-twisted',
7-
version='1.8',
8-
description='A twisted plugin for py.test.',
9-
long_description=open('README.rst').read(),
10-
author='Ralf Schmitt, Kyle Altendorf, Victor Titor',
11-
author_email='[email protected]',
12-
url='https://github.com/pytest-dev/pytest-twisted',
13-
py_modules=['pytest_twisted'],
14-
install_requires=['greenlet', 'pytest>=2.3', 'decorator'],
7+
name="pytest-twisted",
8+
version="1.8",
9+
description="A twisted plugin for py.test.",
10+
long_description=long_description,
11+
author="Ralf Schmitt, Kyle Altendorf, Victor Titor",
12+
author_email="[email protected]",
13+
url="https://github.com/pytest-dev/pytest-twisted",
14+
py_modules=["pytest_twisted"],
15+
install_requires=["greenlet", "pytest>=2.3", "decorator"],
1516
classifiers=[
16-
'Development Status :: 5 - Production/Stable',
17-
'Intended Audience :: Developers',
18-
'License :: OSI Approved :: BSD License',
19-
'Operating System :: OS Independent',
20-
'Programming Language :: Python',
21-
'Topic :: Software Development :: Testing',
22-
'Programming Language :: Python :: 2',
23-
'Programming Language :: Python :: 2.7',
24-
'Programming Language :: Python :: 3',
25-
'Programming Language :: Python :: 3.4',
26-
'Programming Language :: Python :: 3.5',
27-
'Programming Language :: Python :: 3.6',
17+
"Development Status :: 5 - Production/Stable",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: BSD License",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python",
22+
"Topic :: Software Development :: Testing",
23+
"Programming Language :: Python :: 2",
24+
"Programming Language :: Python :: 2.7",
25+
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3.4",
27+
"Programming Language :: Python :: 3.5",
28+
"Programming Language :: Python :: 3.6",
2829
],
29-
entry_points={'pytest11': ['twisted = pytest_twisted']}
30+
entry_points={"pytest11": ["twisted = pytest_twisted"]},
3031
)

0 commit comments

Comments
 (0)