Merge "Quote string representations"

This commit is contained in:
Zuul 2022-06-13 16:32:31 +00:00 committed by Gerrit Code Review
commit 6dfc18013a
7 changed files with 12 additions and 11 deletions

View File

@ -379,7 +379,7 @@ class Atom(object, metaclass=abc.ABCMeta):
"""
def __str__(self):
return "%s==%s" % (self.name, misc.get_version_string(self))
return '"%s==%s"' % (self.name, misc.get_version_string(self))
def __repr__(self):
return '<%s %s>' % (reflection.get_class_name(self), self)

View File

@ -64,7 +64,8 @@ class Terminator(object):
return self._name
def __str__(self):
return "%s[$]" % (self._flow,)
flow_name = ("%s" % self._flow).strip('"')
return '"%s[$]"' % flow_name
class Compilation(object):

View File

@ -116,7 +116,7 @@ class Flow(object, metaclass=abc.ABCMeta):
cls_name = reflection.get_class_name(self)
if cls_name.startswith(_CHOP_PAT):
cls_name = cls_name[_CHOP_PAT_LEN:]
return "%s: %s(len=%d)" % (cls_name, self.name, len(self))
return '"%s: %s(len=%d)"' % (cls_name, self.name, len(self))
@property
def provides(self):

View File

@ -39,7 +39,7 @@ class GraphFlowTest(test.TestCase):
def test_graph_flow_stringy(self):
f = gf.Flow('test')
expected = 'graph_flow.Flow: test(len=0)'
expected = '"graph_flow.Flow: test(len=0)"'
self.assertEqual(expected, str(f))
task1 = _task(name='task1')
@ -47,7 +47,7 @@ class GraphFlowTest(test.TestCase):
task3 = _task(name='task3')
f = gf.Flow('test')
f.add(task1, task2, task3)
expected = 'graph_flow.Flow: test(len=3)'
expected = '"graph_flow.Flow: test(len=3)"'
self.assertEqual(expected, str(f))
def test_graph_flow_starts_as_empty(self):

View File

@ -28,7 +28,7 @@ class LinearFlowTest(test.TestCase):
def test_linear_flow_stringy(self):
f = lf.Flow('test')
expected = 'linear_flow.Flow: test(len=0)'
expected = '"linear_flow.Flow: test(len=0)"'
self.assertEqual(expected, str(f))
task1 = _task(name='task1')
@ -36,7 +36,7 @@ class LinearFlowTest(test.TestCase):
task3 = _task(name='task3')
f = lf.Flow('test')
f.add(task1, task2, task3)
expected = 'linear_flow.Flow: test(len=3)'
expected = '"linear_flow.Flow: test(len=3)"'
self.assertEqual(expected, str(f))
def test_linear_flow_starts_as_empty(self):

View File

@ -28,7 +28,7 @@ class UnorderedFlowTest(test.TestCase):
def test_unordered_flow_stringy(self):
f = uf.Flow('test')
expected = 'unordered_flow.Flow: test(len=0)'
expected = '"unordered_flow.Flow: test(len=0)"'
self.assertEqual(expected, str(f))
task1 = _task(name='task1')
@ -36,7 +36,7 @@ class UnorderedFlowTest(test.TestCase):
task3 = _task(name='task3')
f = uf.Flow('test')
f.add(task1, task2, task3)
expected = 'unordered_flow.Flow: test(len=3)'
expected = '"unordered_flow.Flow: test(len=3)"'
self.assertEqual(expected, str(f))
def test_unordered_flow_starts_as_empty(self):

View File

@ -86,11 +86,11 @@ class TaskTest(test.TestCase):
def test_task_str(self):
my_task = MyTask(name='my')
self.assertEqual('my==1.0', str(my_task))
self.assertEqual('"my==1.0"', str(my_task))
def test_task_repr(self):
my_task = MyTask(name='my')
self.assertEqual('<%s.MyTask my==1.0>' % __name__, repr(my_task))
self.assertEqual('<%s.MyTask "my==1.0">' % __name__, repr(my_task))
def test_no_provides(self):
my_task = MyTask()