Skip to content

Commit

Permalink
Bug 1638990: [taskgraph] Make test_util_parameterization.py pass on p…
Browse files Browse the repository at this point in the history
…ython 3; r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D84076
  • Loading branch information
tomprince committed Jul 20, 2020
1 parent e837225 commit 945a1bc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
32 changes: 0 additions & 32 deletions taskcluster/taskgraph/test/test_util_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

from __future__ import absolute_import, print_function, unicode_literals

import sys
import unittest
import datetime
import mock
import os

import pytest
from mozunit import main
from taskgraph.util.parameterization import (
resolve_timestamps,
Expand All @@ -29,9 +27,6 @@ def test_no_change(self):
}
self.assertEqual(resolve_timestamps(now, input), input)

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_buried_replacement(self):
now = datetime.datetime(2018, 1, 1)
input = {"key": [{"key2": [{'relative-datestamp': '1 day'}]}]}
Expand Down Expand Up @@ -61,41 +56,26 @@ def test_no_change(self):
self.do({'in-a-list': ['stuff', {'property': '<edge1>'}]},
{'in-a-list': ['stuff', {'property': '<edge1>'}]})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_in_list(self):
"resolve_task_references resolves task references in a list"
self.do({'in-a-list': ['stuff', {'task-reference': '<edge1>'}]},
{'in-a-list': ['stuff', 'tid1']})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_in_dict(self):
"resolve_task_references resolves task references in a dict"
self.do({'in-a-dict': {'stuff': {'task-reference': '<edge2>'}}},
{'in-a-dict': {'stuff': 'tid2'}})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_multiple(self):
"resolve_task_references resolves multiple references in the same string"
self.do({'multiple': {'task-reference': 'stuff <edge1> stuff <edge2> after'}},
{'multiple': 'stuff tid1 stuff tid2 after'})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_embedded(self):
"resolve_task_references resolves ebmedded references"
self.do({'embedded': {'task-reference': 'stuff before <edge3> stuff after'}},
{'embedded': 'stuff before tid3 stuff after'})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_escaping(self):
"resolve_task_references resolves escapes in task references"
self.do({'escape': {'task-reference': '<<><edge3>>'}},
Expand All @@ -106,25 +86,16 @@ def test_multikey(self):
self.do({'escape': {'task-reference': '<edge3>', 'another-key': True}},
{'escape': {'task-reference': '<edge3>', 'another-key': True}})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_self(self):
"resolve_task_references resolves `self` to the provided task id"
self.do({'escape': {'task-reference': '<self>'}},
{'escape': 'tid-self'})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_decision(self):
"resolve_task_references resolves `decision` to the provided decision task id"
self.do({'escape': {'task-reference': '<decision>'}},
{'escape': 'tid-decision'})

@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
def test_invalid(self):
"resolve_task_references raises a KeyError on reference to an invalid task"
self.assertRaisesRegexp(
Expand All @@ -136,9 +107,6 @@ def test_invalid(self):
)


@pytest.mark.xfail(
sys.version_info >= (3, 0), reason="python3 migration is not complete"
)
class TestArtifactRefs(unittest.TestCase):

def do(self, input, output):
Expand Down
2 changes: 1 addition & 1 deletion taskcluster/taskgraph/util/parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def recurse(val):
elif isinstance(val, dict):
if len(val) == 1:
for param_key, param_fn in param_fns.items():
if val.keys() == [param_key]:
if set(six.iterkeys(val)) == {param_key}:
return param_fn(val[param_key])
return {k: recurse(v) for k, v in six.iteritems(val)}
else:
Expand Down

0 comments on commit 945a1bc

Please sign in to comment.