Skip test_gen_thin_compression_fallback_py3

Skips this test on Windows running Python 2
This test is causing python to hard crash, thus killing the entire test
suite
Also simplifies the _get_thintar_prefix function
This commit is contained in:
twangboy 2019-04-29 16:56:26 -06:00
parent 6bfca941a9
commit 811b381714
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB
2 changed files with 7 additions and 3 deletions

View file

@ -327,8 +327,10 @@ def _get_thintar_prefix(tarname):
:param tarname: name of the chosen tarball
:return: prefixed tarname
'''
tfd, tmp_tarname = tempfile.mkstemp(dir=os.path.dirname(tarname), prefix=".thin-",
suffix="." + os.path.basename(tarname).split(".", 1)[-1])
tfd, tmp_tarname = tempfile.mkstemp(
dir=os.path.dirname(tarname),
prefix=".thin-",
suffix=os.path.splitext(tarname)[1])
os.close(tfd)
return tmp_tarname
@ -458,7 +460,6 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='',
elif compress == 'zip':
tfp = zipfile.ZipFile(tmp_thintar, 'w', compression=zlib and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED)
tfp.add = tfp.write
try: # cwd may not exist if it was removed but salt was run from it
start_dir = os.getcwd()
except OSError:

View file

@ -17,6 +17,7 @@ import salt.exceptions
from salt.utils import thin
from salt.utils import json
import salt.utils.stringutils
import salt.utils.platform
from salt.utils.stringutils import to_bytes as bts
from salt.ext.six.moves import range
@ -423,6 +424,8 @@ class SSHThinTestCase(TestCase):
self.assertIn('The minimum required python version to run salt-ssh is '
'"2.6"', str(err.value))
@skipIf(salt.utils.platform.is_windows() and thin._six.PY2,
'Dies on Python2 on Windows')
@patch('salt.exceptions.SaltSystemExit', Exception)
@patch('salt.utils.thin.log', MagicMock())
@patch('salt.utils.thin.os.makedirs', MagicMock())