Merge lp:~stub/charm-helpers/bug-1458546-fix-relation-set-py3 into lp:charm-helpers

Proposed by Stuart Bishop
Status: Rejected
Rejected by: Chris Glass
Proposed branch: lp:~stub/charm-helpers/bug-1458546-fix-relation-set-py3
Merge into: lp:charm-helpers
Diff against target: 26 lines (+3/-2)
2 files modified
charmhelpers/core/hookenv.py (+1/-1)
tests/core/test_hookenv.py (+2/-1)
To merge this branch: bzr merge lp:~stub/charm-helpers/bug-1458546-fix-relation-set-py3
Reviewer Review Type Date Requested Status
Chris Glass Pending
Review via email: mp+260048@code.launchpad.net

Description of the change

Fix hookenv.relation_set() under Python 3

(because everything you write with Python 2 is techdebt ;) )

To post a comment you must log in.
380. By Stuart Bishop

Link to the bug

Revision history for this message
Chris Glass (tribaal) wrote :

The contents of this branch are added to main thought https://code.launchpad.net/~free.ekanayaka/charm-helpers/relation-set-file/+merge/260594

Closing this one since it is now redundant.

Unmerged revisions

380. By Stuart Bishop

Link to the bug

379. By Stuart Bishop

Fix subprocess call in hookenv.relation_set

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/core/hookenv.py'
--- charmhelpers/core/hookenv.py 2015-05-20 22:56:01 +0000
+++ charmhelpers/core/hookenv.py 2015-05-25 13:06:56 +0000
@@ -364,7 +364,7 @@
364 relation_settings = relation_settings if relation_settings else {}364 relation_settings = relation_settings if relation_settings else {}
365 relation_cmd_line = ['relation-set']365 relation_cmd_line = ['relation-set']
366 accepts_file = "--file" in subprocess.check_output(366 accepts_file = "--file" in subprocess.check_output(
367 relation_cmd_line + ["--help"])367 relation_cmd_line + ["--help"], universal_newlines=True)
368 if relation_id is not None:368 if relation_id is not None:
369 relation_cmd_line.extend(('-r', relation_id))369 relation_cmd_line.extend(('-r', relation_id))
370 settings = relation_settings.copy()370 settings = relation_settings.copy()
371371
=== modified file 'tests/core/test_hookenv.py'
--- tests/core/test_hookenv.py 2015-05-20 22:56:01 +0000
+++ tests/core/test_hookenv.py 2015-05-25 13:06:56 +0000
@@ -970,7 +970,8 @@
970 # whether we can pass --file to it.970 # whether we can pass --file to it.
971 check_output.return_value = "--file"971 check_output.return_value = "--file"
972 hookenv.relation_set(foo="bar")972 hookenv.relation_set(foo="bar")
973 check_output.assert_called_with(["relation-set", "--help"])973 check_output.assert_called_with(["relation-set", "--help"],
974 universal_newlines=True)
974 # relation-set is called with relation-set --file <temp_file>975 # relation-set is called with relation-set --file <temp_file>
975 # with data as YAML and the temp_file is then removed.976 # with data as YAML and the temp_file is then removed.
976 self.assertEqual(1, len(check_call.call_args[0]))977 self.assertEqual(1, len(check_call.call_args[0]))

Subscribers

People subscribed via source and target branches