issue #575: fix exception text rendering

pull/595/head
David Wilson 6 years ago
parent 9739f550ab
commit 65deb3feac

@ -93,7 +93,7 @@ MAKE_TEMP_FAILED_MSG = (
u"were mounted on 'noexec' filesystems.\n"
u"\n"
u"The following paths were tried:\n"
u" %(namelist)s\n"
u" %(paths)s\n"
u"\n"
u"Please check '-vvv' output for a log of individual path errors."
)

@ -27,6 +27,10 @@ Fixes
* `#557 <https://github.com/dw/mitogen/issues/557>`_: fix a crash when running
on machines with high CPU counts.
* `#575 <https://github.com/dw/mitogen/issues/575>`_: fix a crash when
rendering an error message to indicate no usable temporary directories could
be found.
* `#570 <https://github.com/dw/mitogen/issues/570>`_: the ``firewalld`` module
internally caches a dbus name that changes across ``firewalld`` restarts,
causing a failure if the service is restarted between ``firewalld`` module invocations.
@ -37,7 +41,8 @@ Thanks!
Mitogen would not be possible without the support of users. A huge thanks for
bug reports, testing, features and fixes in this release contributed by
`Orion Poplawski <https://github.com/opoplawski>`_, and
`Orion Poplawski <https://github.com/opoplawski>`_,
`Thibaut Barrère <https://github.com/thbar>`_, and
`@Moumoutaru <https://github.com/Moumoutaru>`_.

@ -15,14 +15,47 @@ LOGGER_NAME = ansible_mitogen.target.LOG.name
class NamedTemporaryDirectory(object):
def __init__(self, **kwargs):
self.kwargs = kwargs
def __enter__(self):
self.path = tempfile.mkdtemp()
self.path = tempfile.mkdtemp(**self.kwargs)
return self.path
def __exit__(self, _1, _2, _3):
subprocess.check_call(['rm', '-rf', self.path])
class FindGoodTempDirTest(testlib.TestCase):
func = staticmethod(ansible_mitogen.target.find_good_temp_dir)
def test_expands_usernames(self):
with NamedTemporaryDirectory(
prefix='.ansible_mitogen_test',
dir=os.environ['HOME']
) as tmpdir:
path = self.func(['~'])
self.assertTrue(path.startswith(os.environ['HOME']))
def test_expands_vars(self):
with NamedTemporaryDirectory(
prefix='.ansible_mitogen_test',
dir=os.environ['HOME']
) as tmpdir:
os.environ['somevar'] = 'xyz'
path = self.func([tmpdir + '/$somevar'])
self.assertTrue(path.startswith('%s/%s' % (tmpdir, 'xyz')))
@mock.patch('ansible_mitogen.target.is_good_temp_dir')
def test_no_good_candidate(self, is_good_temp_dir):
is_good_temp_dir.return_value = False
e = self.assertRaises(IOError,
lambda: self.func([])
)
self.assertTrue(str(e).startswith('Unable to find a useable'))
class ApplyModeSpecTest(unittest2.TestCase):
func = staticmethod(ansible_mitogen.target.apply_mode_spec)

Loading…
Cancel
Save