import arvados
import arvados_fuse
import arvados_fuse.command
+import contextlib
import functools
import json
import llfuse
import logging
import os
import run_test_server
+import sys
import tempfile
import unittest
raise SystemExitCaught
return wrapper
+@contextlib.contextmanager
+def nostderr():
+ orig, sys.stderr = sys.stderr, open(os.devnull, 'w')
+ try:
+ yield
+ finally:
+ sys.stderr = orig
+
+
class MountArgsTest(unittest.TestCase):
def setUp(self):
self.mntdir = tempfile.mkdtemp()
['--by-id', '--project', gid],
['--mount-tmp', 'foo', '--by-id'],
]:
- with self.assertRaises(SystemExit):
- args = arvados_fuse.command.ArgumentParser().parse_args(
- badargs + ['--foreground', self.mntdir])
- arvados_fuse.command.Mount(args)
+ with nostderr():
+ with self.assertRaises(SystemExit):
+ args = arvados_fuse.command.ArgumentParser().parse_args(
+ badargs + ['--foreground', self.mntdir])
+ arvados_fuse.command.Mount(args)
@noexit
def test_project(self):
uuid = run_test_server.fixture('groups')['aproject']['uuid']
def test_custom_unsupported_layouts(self):
for name in ['.', '..', '', 'foo/bar', '/foo']:
- with self.assertRaises(SystemExit):
- args = arvados_fuse.command.ArgumentParser().parse_args([
- '--mount-tmp', name,
- '--foreground', self.mntdir])
- arvados_fuse.command.Mount(args)
+ with nostderr():
+ with self.assertRaises(SystemExit):
+ args = arvados_fuse.command.ArgumentParser().parse_args([
+ '--mount-tmp', name,
+ '--foreground', self.mntdir])
+ arvados_fuse.command.Mount(args)