Skip to content

Commit ee817b8

Browse files
committed
Switch from --qt5reactor to --reactor=qt5reactor
1 parent ca7778e commit ee817b8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

pytest_twisted.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,18 @@ def init_qt5_reactor(qapp):
136136

137137
def pytest_addoption(parser):
138138
group = parser.getgroup('twisted')
139-
group.addoption('--qt5reactor', dest='qt5reactor', action='store_true',
140-
help='prepare for use with qt5reactor')
139+
group.addoption(
140+
'--reactor',
141+
default='default',
142+
choices=('default', 'qt5reactor'),
143+
)
141144

142145

143146
def pytest_configure(config):
144-
reactor_fixture = init_reactor
145-
if config.getoption('qt5reactor'):
146-
reactor_fixture = init_qt5_reactor
147+
reactor_fixture = {
148+
'default': init_reactor,
149+
'qt5reactor': init_qt5_reactor,
150+
}[config.getoption('reactor')]
147151

148152
class ReactorPlugin(object):
149153
reactor = staticmethod(

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ deps=
1515
qt5reactor: pytest-xvfb
1616
qt5reactor: pyqt5
1717
setenv=
18-
defaultreactor: reactor_option=
19-
qt5reactor: reactor_option=--qt5reactor
20-
commands=py.test {env:reactor_option} []
18+
defaultreactor: reactor_option=default
19+
qt5reactor: reactor_option=qt5reactor
20+
commands=py.test --reactor={env:reactor_option} []
2121
sitepackages=False
2222

2323
[testenv:py26-defaultreactor]

0 commit comments

Comments
 (0)