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
1=== modified file 'charmhelpers/core/hookenv.py'
2--- charmhelpers/core/hookenv.py 2015-05-20 22:56:01 +0000
3+++ charmhelpers/core/hookenv.py 2015-05-25 13:06:56 +0000
4@@ -364,7 +364,7 @@
5 relation_settings = relation_settings if relation_settings else {}
6 relation_cmd_line = ['relation-set']
7 accepts_file = "--file" in subprocess.check_output(
8- relation_cmd_line + ["--help"])
9+ relation_cmd_line + ["--help"], universal_newlines=True)
10 if relation_id is not None:
11 relation_cmd_line.extend(('-r', relation_id))
12 settings = relation_settings.copy()
13
14=== modified file 'tests/core/test_hookenv.py'
15--- tests/core/test_hookenv.py 2015-05-20 22:56:01 +0000
16+++ tests/core/test_hookenv.py 2015-05-25 13:06:56 +0000
17@@ -970,7 +970,8 @@
18 # whether we can pass --file to it.
19 check_output.return_value = "--file"
20 hookenv.relation_set(foo="bar")
21- check_output.assert_called_with(["relation-set", "--help"])
22+ check_output.assert_called_with(["relation-set", "--help"],
23+ universal_newlines=True)
24 # relation-set is called with relation-set --file <temp_file>
25 # with data as YAML and the temp_file is then removed.
26 self.assertEqual(1, len(check_call.call_args[0]))

Subscribers

People subscribed via source and target branches