Skip to content

Commit 74bb9ee

Browse files
committed
Stop repeating reactor option strings
1 parent edcac00 commit 74bb9ee

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pytest_twisted.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ def init_qt5_reactor(qapp):
147147
)
148148

149149

150+
_reactor_fixtures = {
151+
'default': init_default_reactor,
152+
'qt5reactor': init_qt5_reactor,
153+
}
154+
155+
150156
def _init_reactor():
151157
import twisted.internet.reactor
152158
_instances.reactor = twisted.internet.reactor
@@ -173,15 +179,12 @@ def pytest_addoption(parser):
173179
group.addoption(
174180
'--reactor',
175181
default='default',
176-
choices=('default', 'qt5reactor'),
182+
choices=tuple(_reactor_fixtures.keys()),
177183
)
178184

179185

180186
def pytest_configure(config):
181-
reactor_fixture = {
182-
'default': init_default_reactor,
183-
'qt5reactor': init_qt5_reactor,
184-
}[config.getoption('reactor')]
187+
reactor_fixture = _reactor_fixtures[config.getoption('reactor')]
185188

186189
class ReactorPlugin(object):
187190
reactor = staticmethod(

0 commit comments

Comments
 (0)