snakeoil
snakeoil copied to clipboard
TestNamespace::test_uts_namespace fails when run via tox
Full log: py38.log
Apparently socket.getfqdn() != socket.gethostname() (the latter returns host as expected). According to docs, it's trying to do some resolver magic, so it might be that.
=================================== FAILURES ===================================
_______________________ TestNamespace.test_uts_namespace _______________________
self = <test_contexts.TestNamespace object at 0x7f993b1840d0>
@pytest.mark.skipif(not (os.path.exists('/proc/self/ns/user') and os.path.exists('/proc/self/ns/uts')),
reason='user and uts namespace support required')
def test_uts_namespace(self):
try:
with Namespace(user=True, uts=True, hostname='host') as ns:
> ns_hostname, _, ns_domainname = socket.getfqdn().partition('.')
tests/module/test_contexts.py:127:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <test_contexts.TestNamespace object at 0x7f993b1840d0>
@pytest.mark.skipif(not (os.path.exists('/proc/self/ns/user') and os.path.exists('/proc/self/ns/uts')),
reason='user and uts namespace support required')
def test_uts_namespace(self):
try:
with Namespace(user=True, uts=True, hostname='host') as ns:
> ns_hostname, _, ns_domainname = socket.getfqdn().partition('.')
tests/module/test_contexts.py:127:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <snakeoil.contexts.Namespace object at 0x7f993b171850>
frame = <frame at 0x563be90e7f00, file '/home/mgorny/git/snakeoil/tests/module/test_contexts.py', line 131, code test_uts_namespace>
event = 'line', arg = None
def __invoke_trace_funcs(self, frame, event, arg):
"""Invoke all trace funcs that have been injected.
Once the injected functions have been executed all trace hooks are
removed in order to minimize overhead.
"""
try:
for func in self.__injected_trace_funcs[frame]:
> func(frame, event, arg)
.tox/py38/lib/python3.8/site-packages/snakeoil/contexts.py:237:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <snakeoil.contexts.Namespace object at 0x7f993b171850>
frame = <frame at 0x563be90e7f00, file '/home/mgorny/git/snakeoil/tests/module/test_contexts.py', line 131, code test_uts_namespace>
event = 'line', arg = None
def __exit_context(self, frame, event, arg):
"""Simple function to throw a ParentException."""
> raise self.ParentException()
E snakeoil.contexts.SplitExec.ParentException
.tox/py38/lib/python3.8/site-packages/snakeoil/contexts.py:212: ParentException
During handling of the above exception, another exception occurred:
self = <test_contexts.TestNamespace object at 0x7f993b1840d0>
@pytest.mark.skipif(not (os.path.exists('/proc/self/ns/user') and os.path.exists('/proc/self/ns/uts')),
reason='user and uts namespace support required')
def test_uts_namespace(self):
try:
with Namespace(user=True, uts=True, hostname='host') as ns:
ns_hostname, _, ns_domainname = socket.getfqdn().partition('.')
assert ns_hostname == 'host'
> assert ns_domainname == ''
tests/module/test_contexts.py:129:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <snakeoil.contexts.Namespace object at 0x7f993b171850>
exc_type = <class 'snakeoil.contexts.SplitExec.ParentException'>
exc_value = ParentException()
exc_traceback = <traceback object at 0x7f993b174ac0>
def __exit__(self, exc_type, exc_value, exc_traceback):
if self.childpid is not None:
# make sure system tracing function is reset
self.__revert_tracing(inspect.currentframe())
# re-raise unknown exceptions from the parent
if exc_type is not self.ParentException:
raise exc_value
# get exception from the child
try:
exc = self.__pipe.recv()
self.locals = exc._locals
except EOFError as e:
exc = SystemExit(e)
# handle child exiting abnormally
if not isinstance(exc, SystemExit):
os.waitpid(self.childpid, 0)
self._exception_cleanup()
sys.excepthook = self.__excepthook
> raise exc
E AssertionError: assert 'pomiot' == 'host'
E - host
E + pomiot
.tox/py38/lib/python3.8/site-packages/snakeoil/contexts.py:163: AssertionError
__________________ TestNamespaceDecorator.test_uts_namespace ___________________
args = (), kwargs = {}
@wraps(func)
def wrapper(*args, **kwargs):
with Namespace(**namespaces):
> return func(*args, **kwargs)
.tox/py38/lib/python3.8/site-packages/snakeoil/decorators.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (), kwargs = {}
@wraps(func)
def wrapper(*args, **kwargs):
with Namespace(**namespaces):
> return func(*args, **kwargs)
.tox/py38/lib/python3.8/site-packages/snakeoil/decorators.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <snakeoil.contexts.Namespace object at 0x7f993b1cac70>
frame = <frame at 0x7f993b0f7420, file '/home/mgorny/git/snakeoil/.tox/py38/lib/python3.8/site-packages/snakeoil/decorators.py', line 23, code wrapper>
event = 'line', arg = None
def __invoke_trace_funcs(self, frame, event, arg):
"""Invoke all trace funcs that have been injected.
Once the injected functions have been executed all trace hooks are
removed in order to minimize overhead.
"""
try:
for func in self.__injected_trace_funcs[frame]:
> func(frame, event, arg)
.tox/py38/lib/python3.8/site-packages/snakeoil/contexts.py:237:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <snakeoil.contexts.Namespace object at 0x7f993b1cac70>
frame = <frame at 0x7f993b0f7420, file '/home/mgorny/git/snakeoil/.tox/py38/lib/python3.8/site-packages/snakeoil/decorators.py', line 23, code wrapper>
event = 'line', arg = None
def __exit_context(self, frame, event, arg):
"""Simple function to throw a ParentException."""
> raise self.ParentException()
E snakeoil.contexts.SplitExec.ParentException
.tox/py38/lib/python3.8/site-packages/snakeoil/contexts.py:212: ParentException
During handling of the above exception, another exception occurred:
self = <test_decorators.TestNamespaceDecorator object at 0x7f993b1603a0>
@pytest.mark.skipif(not (os.path.exists('/proc/self/ns/user') and os.path.exists('/proc/self/ns/uts')),
reason='user and uts namespace support required')
def test_uts_namespace(self):
@namespace(user=True, uts=True, hostname='host')
def do_test():
ns_hostname, _, ns_domainname = socket.getfqdn().partition('.')
assert ns_hostname == 'host'
assert ns_domainname == ''
try:
> do_test()
tests/module/test_decorators.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py38/lib/python3.8/site-packages/snakeoil/decorators.py:23: in wrapper
return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <snakeoil.contexts.Namespace object at 0x7f993b1cac70>
exc_type = <class 'snakeoil.contexts.SplitExec.ParentException'>
exc_value = ParentException()
exc_traceback = <traceback object at 0x7f993b10dc80>
def __exit__(self, exc_type, exc_value, exc_traceback):
if self.childpid is not None:
# make sure system tracing function is reset
self.__revert_tracing(inspect.currentframe())
# re-raise unknown exceptions from the parent
if exc_type is not self.ParentException:
raise exc_value
# get exception from the child
try:
exc = self.__pipe.recv()
self.locals = exc._locals
except EOFError as e:
exc = SystemExit(e)
# handle child exiting abnormally
if not isinstance(exc, SystemExit):
os.waitpid(self.childpid, 0)
self._exception_cleanup()
sys.excepthook = self.__excepthook
> raise exc
E AssertionError: assert 'pomiot' == 'host'
E - host
E + pomiot
.tox/py38/lib/python3.8/site-packages/snakeoil/contexts.py:163: AssertionError
=========================== short test summary info ============================
FAILED tests/module/test_contexts.py::TestNamespace::test_uts_namespace - Ass...
FAILED tests/module/test_decorators.py::TestNamespaceDecorator::test_uts_namespace
================== 2 failed, 522 passed, 50 skipped in 28.96s ==================
ERROR: InvocationError for command /home/mgorny/git/snakeoil/.tox/py38/bin/coverage run -p -m pytest -v (exited with code 1)
___________________________________ summary ____________________________________
ERROR: py38: commands failed