tests: Allow custom args when starting testprocess.
This commit is contained in:
parent
eb276df876
commit
ef17c86586
@ -207,10 +207,11 @@ class QuteProc(testprocess.Process):
|
||||
else:
|
||||
executable = sys.executable
|
||||
args = ['-m', 'qutebrowser']
|
||||
args += ['--debug', '--no-err-windows', '--temp-basedir',
|
||||
'about:blank']
|
||||
return executable, args
|
||||
|
||||
def _default_args(self):
|
||||
return ['--debug', '--no-err-windows', '--temp-basedir', 'about:blank']
|
||||
|
||||
def path_to_url(self, path, *, port=None, https=False):
|
||||
"""Get a URL based on a filename for the localhost webserver.
|
||||
|
||||
|
@ -73,6 +73,9 @@ class PythonProcess(testprocess.Process):
|
||||
]
|
||||
return (sys.executable, ['-c', ';'.join(code)])
|
||||
|
||||
def _default_args(self):
|
||||
return []
|
||||
|
||||
|
||||
class QuitPythonProcess(testprocess.Process):
|
||||
|
||||
@ -96,6 +99,9 @@ class QuitPythonProcess(testprocess.Process):
|
||||
]
|
||||
return (sys.executable, ['-c', ';'.join(code)])
|
||||
|
||||
def _default_args(self):
|
||||
return []
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def pyproc():
|
||||
|
@ -159,7 +159,11 @@ class Process(QObject):
|
||||
raise NotImplementedError
|
||||
|
||||
def _executable_args(self):
|
||||
"""Get the executable and arguments to pass to it as a tuple."""
|
||||
"""Get the executable and necessary arguments as a tuple."""
|
||||
raise NotImplementedError
|
||||
|
||||
def _default_args(self):
|
||||
"""Get the default arguments to use if none were passed to start()."""
|
||||
raise NotImplementedError
|
||||
|
||||
def _get_data(self):
|
||||
@ -208,16 +212,18 @@ class Process(QObject):
|
||||
self._data.append(parsed)
|
||||
self.new_data.emit(parsed)
|
||||
|
||||
def start(self):
|
||||
def start(self, args=None):
|
||||
"""Start the process and wait until it started."""
|
||||
with self._wait_signal(self.ready, timeout=60000):
|
||||
self._start()
|
||||
self._start(args)
|
||||
|
||||
def _start(self):
|
||||
def _start(self, args):
|
||||
"""Actually start the process."""
|
||||
executable, args = self._executable_args()
|
||||
executable, exec_args = self._executable_args()
|
||||
if args is None:
|
||||
args = self._default_args()
|
||||
self.proc.readyRead.connect(self.read_log)
|
||||
self.proc.start(executable, args)
|
||||
self.proc.start(executable, exec_args + args)
|
||||
ok = self.proc.waitForStarted()
|
||||
assert ok
|
||||
assert self.is_running()
|
||||
|
@ -154,14 +154,17 @@ class WebserverProcess(testprocess.Process):
|
||||
if hasattr(sys, 'frozen'):
|
||||
executable = os.path.join(os.path.dirname(sys.executable),
|
||||
self._script)
|
||||
args = [str(self.port)]
|
||||
args = []
|
||||
else:
|
||||
executable = sys.executable
|
||||
py_file = os.path.join(os.path.dirname(__file__),
|
||||
self._script + '.py')
|
||||
args = [py_file, str(self.port)]
|
||||
args = [py_file]
|
||||
return executable, args
|
||||
|
||||
def _default_args(self):
|
||||
return [str(self.port)]
|
||||
|
||||
def cleanup(self):
|
||||
"""Clean up and shut down the process."""
|
||||
self.proc.terminate()
|
||||
|
Loading…
Reference in New Issue
Block a user