Skip to content

Commit

Permalink
Merge pull request #49390 from dwoz/archive_module
Browse files Browse the repository at this point in the history
[2017.7] Fix archive tests for py3
  • Loading branch information
Nicole Thomas committed Aug 29, 2018
2 parents c591d2b + b332beb commit 651631d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions tests/integration/modules/test_archive.py
Expand Up @@ -65,6 +65,10 @@ def _set_up(self, arch_fmt, unicode_filename=False):
else:
filename = 'file'
with salt.utils.fopen(os.path.join(self.src, filename), 'wb') as theorem:
if six.PY3 and salt.utils.is_windows():
encoding = 'utf-8'
else:
encoding = None
theorem.write(salt.utils.to_bytes(textwrap.dedent('''\
Compression theorem of computational complexity theory:
Expand All @@ -82,7 +86,7 @@ def _set_up(self, arch_fmt, unicode_filename=False):
and
$\\mathrm C(φ_i) ⊊ \\mathrm{C}(φ_{f(i)})$.
''')))
'''), encoding=encoding))

# Create destination
os.makedirs(self.dst)
Expand Down Expand Up @@ -124,10 +128,10 @@ def normdir(path):
dir_in_ret = None
file_in_ret = None
for line in ret:
if normdir(self.src) in line \
and not normdir(self.src_file) in line:
if normdir(self.src) in os.path.normcase(line) \
and not normdir(self.src_file) in os.path.normcase(line):
dir_in_ret = True
if normdir(self.src_file) in line:
if normdir(self.src_file) in os.path.normcase(line):
file_in_ret = True

# Assert number of lines, reporting of source directory and file
Expand Down Expand Up @@ -250,7 +254,7 @@ def test_unzip(self):
# Test create archive
ret = self.run_function('archive.unzip', [self.arch, self.dst])
self.assertTrue(isinstance(ret, list), six.text_type(ret))
self._assert_artifacts_in_ret(ret, unix_sep=True if six.PY2 else False)
self._assert_artifacts_in_ret(ret, unix_sep=False)

self._tear_down()

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/modules/test_system.py
Expand Up @@ -11,7 +11,7 @@
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import destructiveTest, skip_if_not_root, flaky

# Import salt libs
import salt.utils
Expand Down Expand Up @@ -251,6 +251,7 @@ def test_set_system_date_time_utcoffset_west(self):
self.assertTrue(self._same_times(time_now, cmp_time), msg=msg)
self._test_hwclock_sync()

@flaky
@destructiveTest
@skip_if_not_root
def test_set_system_time(self):
Expand Down

0 comments on commit 651631d

Please sign in to comment.