Bug 1636209: resolves tests that were incorrectly marked as xfail r=tomprince

When handling bug 1632429, I found some tests that worked on Python 2, but not Python 3.
They were marked accordingly as "expected failures". However, my system version of Python
is 3.8, while CI (and a non-trivial number of devs, probably) use 3.6.

Some of these tests marked as xfail were actually still working on versions of Python until 3.8.

The failure of this test was due to a change in default tarfile format. Explicitly setting this
format makes the tests pass in all relevant python versions.

Differential Revision: https://phabricator.services.mozilla.com/D74337
This commit is contained in:
Mitchell Hentges 2020-05-07 23:41:35 +00:00
Родитель 2fee157360
Коммит 2e71833471
2 изменённых файлов: 4 добавлений и 16 удалений

Просмотреть файл

@ -30,7 +30,10 @@ def create_tar_from_files(fp, files):
FUTURE accept a filename argument (or create APIs to write files)
"""
with tarfile.open(name='', mode='w', fileobj=fp, dereference=True) as tf:
# The format is explicitly set to tarfile.GNU_FORMAT, because this default format
# has been changed in Python 3.8.
with tarfile.open(name='', mode='w', fileobj=fp, dereference=True,
format=tarfile.GNU_FORMAT) as tf:
for archive_path, f in sorted(files.items()):
if not isinstance(f, BaseFile):
f = File(f)

Просмотреть файл

@ -7,12 +7,10 @@ from __future__ import absolute_import, print_function, unicode_literals
import os
import shutil
import stat
import sys
import tarfile
import tempfile
import unittest
import mock
import pytest
import taskcluster_urls as liburls
from taskgraph.util import docker
@ -24,10 +22,6 @@ MODE_STANDARD = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
@mock.patch.dict('os.environ', {'TASKCLUSTER_ROOT_URL': liburls.test_root_url()})
class TestDocker(unittest.TestCase):
@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_generate_context_hash(self):
tmpdir = tempfile.mkdtemp()
try:
@ -81,9 +75,6 @@ class TestDocker(unittest.TestCase):
with MockedOpen(files):
self.assertEqual(docker.docker_image('myimage', by_tag=True), "mozilla/myimage:1.2.3")
@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_create_context_tar_basic(self):
tmp = tempfile.mkdtemp()
try:
@ -110,9 +101,6 @@ class TestDocker(unittest.TestCase):
finally:
shutil.rmtree(tmp)
@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_create_context_topsrcdir_files(self):
tmp = tempfile.mkdtemp()
try:
@ -183,9 +171,6 @@ class TestDocker(unittest.TestCase):
finally:
shutil.rmtree(tmp)
@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_create_context_extra_directory(self):
tmp = tempfile.mkdtemp()
try: