web_api_mock = <requests_mock.mocker.Mocker object at 0x7f23e63d3be0>
@pytest.fixture
def fuse_mntdir(web_api_mock):
tmpdir = TemporaryDirectory(suffix=".swh-fuse-test")
# Run FUSE in foreground mode but in a separate process, so it does not
# block execution and remains easy to kill during teardown
def fuse_process(tmpdir):
with tmpdir as mntdir:
CliRunner().invoke(
cli.mount,
args=[
mntdir,
ROOT_SWHID,
"--foreground",
"--cache-dir",
":memory:",
"--api-url",
API_URL,
],
)
fuse = Process(target=fuse_process, args=[tmpdir])
fuse.start()
# Wait max 3 seconds for the FUSE to correctly mount
i = 0
while i < 30:
try:
root = listdir(tmpdir.name)
if root:
break
except FileNotFoundError:
i += 1
time.sleep(0.1)
yield tmpdir.name
> subprocess.run(["fusermount", "-u", tmpdir.name], check=True)
.tox/py3/lib/python3.7/site-packages/swh/fuse/tests/conftest.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['fusermount', '-u', '/tmp/tmp_l2e5jkb.swh-fuse-test'],)
kwargs = {}, process = <subprocess.Popen object at 0x7f23e63e2f60>
stdout = None, stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if 'stdin' in kwargs:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if ('stdout' in kwargs) or ('stderr' in kwargs):
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired:
process.kill()
stdout, stderr = process.communicate()
raise TimeoutExpired(process.args, timeout, output=stdout,
stderr=stderr)
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
raise CalledProcessError(retcode, process.args,
> output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['fusermount', '-u', '/tmp/tmp_l2e5jkb.swh-fuse-test']' returned non-zero exit status 1.
/usr/lib/python3.7/subprocess.py:487: CalledProcessError
TEST RESULT
TEST RESULT
- Run At
- Oct 1 2020, 3:31 PM