Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port test/tasks #6255

Merged
merged 2 commits into from Jul 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/python/pants_test/tasks/task_test_base.py
Expand Up @@ -7,7 +7,9 @@
import glob
import os
from contextlib import closing, contextmanager
from StringIO import StringIO
from io import BytesIO

from future.utils import PY2

from pants.base.deprecated import deprecated_module
from pants.goal.goal import Goal
Expand Down Expand Up @@ -107,7 +109,9 @@ def synthesize_task_subtype(self, task_type, options_scope):
:param options_scope: The scope to give options on the generated task type.
:return: A pair (type, options_scope)
"""
subclass_name = b'test_{0}_{1}'.format(task_type.__name__, options_scope)
subclass_name = 'test_{0}_{1}'.format(task_type.__name__, options_scope)
if PY2:
subclass_name = subclass_name.encode('utf-8')
return type(subclass_name, (task_type,), {'_stable_name': task_type._compute_stable_name(),
'options_scope': options_scope})

Expand Down Expand Up @@ -193,7 +197,7 @@ def execute_task(self, targets=None, options=None):
Returns the text output of the task.
"""
options = options or {}
with closing(StringIO()) as output:
with closing(BytesIO()) as output:
self.set_options(**options)
context = self.context(target_roots=targets, console_outstream=output)
task = self.create_task(context)
Expand Down
9 changes: 7 additions & 2 deletions tests/python/pants_test/tasks/test_execution_graph.py
Expand Up @@ -6,8 +6,11 @@

import re
import unittest
from builtins import object, str
from collections import defaultdict

from future.utils import PY3

from pants.backend.jvm.tasks.jvm_compile.execution_graph import (ExecutionFailure, ExecutionGraph,
Job, JobExistsError,
NoRootJobError, UnknownJobError)
Expand Down Expand Up @@ -187,7 +190,8 @@ def test_non_existent_dependency_causes_failure(self):
ExecutionGraph([self.job("A", passing_fn, []),
self.job("B", passing_fn, ["Z"])], False)

self.assertEqual("Unexecutable graph: Undefined dependencies u'Z'", str(cm.exception))
self.assertEqual("Unexecutable graph: Undefined dependencies " + ("'Z'" if PY3 else "u'Z'"),
str(cm.exception))

def test_on_success_callback_raises_error(self):
exec_graph = ExecutionGraph([self.job("A", passing_fn, [], on_success=raising_fn)], False)
Expand All @@ -210,7 +214,8 @@ def test_same_key_scheduled_twice_is_error(self):
ExecutionGraph([self.job("Same", passing_fn, []),
self.job("Same", passing_fn, [])], False)

self.assertEqual("Unexecutable graph: Job already scheduled u'Same'", str(cm.exception))
self.assertEqual("Unexecutable graph: Job already scheduled " + ("'Same'" if PY3 else "u'Same'"),
str(cm.exception))

def test_priorities_for_chain_of_jobs(self):
exec_graph = ExecutionGraph([self.job("A", passing_fn, [], 8),
Expand Down