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

Python 3 fixes - various bytes vs unicode issues #6311

Merged
merged 10 commits into from Aug 7, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Aug 6, 2018

Fixes multiple issues resulting from running unit tests in Python 3.

Addresses the folders not covered by earlier sweep made by #6287.

@@ -99,8 +99,9 @@ def execute(self):
with self.assertRaises(GoalError) as ctx:
goal.install(TaskRegistrar(task_name, OtherNoopTask))

self.assertIn('foo', ctx.exception.message)
self.assertIn(self._LIST_GOALS_NAME, ctx.exception.message)
exception_message = ' '.join(ctx.exception.args)

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Aug 6, 2018

Contributor

Py3 doesn't have exception.message. Both have exception.args though, which is a tuple we convert to a string.

This comment has been minimized.

@illicitonion

illicitonion Aug 7, 2018

Contributor

I believe str(ctx.exception) consistently gives exception.message on both Pythons

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Aug 7, 2018

Contributor

You're right! Good catch.

@@ -204,7 +205,13 @@ def test_site_toc(self):
{{/site_toc}}
""")
self.assertIn("DEPTH=1 LINK=None HEADING=non_collapse", rendered)
self.assertIn(u"DEPTH=1 LINK=[{'text': u'Page 2: Electric Boogaloo', 'link': u'subdir/page2.html', 'here': False}, {'text': u'Pants Build System', 'link': u'index.html', 'here': True}] HEADING=collapse", rendered)
# Py2 and Py3 order the elements differently and Py3 doesn't render 'u' in unicode literals. Both are valid.

This comment has been minimized.

@illicitonion

illicitonion Aug 7, 2018

Contributor

I'm pretty sure that neither of these orderings should be deterministic :S

But, if the tests are solid...

@@ -99,8 +99,9 @@ def execute(self):
with self.assertRaises(GoalError) as ctx:
goal.install(TaskRegistrar(task_name, OtherNoopTask))

self.assertIn('foo', ctx.exception.message)
self.assertIn(self._LIST_GOALS_NAME, ctx.exception.message)
exception_message = ' '.join(ctx.exception.args)

This comment has been minimized.

@illicitonion

illicitonion Aug 7, 2018

Contributor

I believe str(ctx.exception) consistently gives exception.message on both Pythons

@illicitonion illicitonion merged commit d14943d into pantsbuild:master Aug 7, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:py3-fixes_unit-tests-pt2 branch Aug 11, 2018

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - various bytes vs unicode issues (pantsbuild#6311)
Fixes multiple issues resulting from running unit tests in Python 3.

Addresses the folders not covered by earlier sweep made by pantsbuild#6287.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment