Merge lp:~james-page/charm-helpers/cleanup_flake8 into lp:charm-helpers

Proposed by James Page
Status: Merged
Approved by: Adam Gandelman
Approved revision: 48
Merged at revision: 54
Proposed branch: lp:~james-page/charm-helpers/cleanup_flake8
Merge into: lp:charm-helpers
Diff against target: 138 lines (+20/-20)
3 files modified
charmhelpers/core/hookenv.py (+1/-0)
tests/core/test_hookenv.py (+14/-13)
tests/payload/test_execd.py (+5/-7)
To merge this branch: bzr merge lp:~james-page/charm-helpers/cleanup_flake8
Reviewer Review Type Date Requested Status
Charm Helper Maintainers Pending
Review via email: mp+174129@code.launchpad.net

Description of the change

Tidy flake8 warnings from core packages and associated tests.

These where annoying me on every review I did so I fixed them up.

To post a comment you must log in.

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 2013-07-05 18:22:23 +0000
3+++ charmhelpers/core/hookenv.py 2013-07-11 08:33:31 +0000
4@@ -335,5 +335,6 @@
5 return decorated
6 return wrapper
7
8+
9 def charm_dir():
10 return os.environ.get('CHARM_DIR')
11
12=== modified file 'tests/core/test_hookenv.py'
13--- tests/core/test_hookenv.py 2013-07-05 18:43:41 +0000
14+++ tests/core/test_hookenv.py 2013-07-11 08:33:31 +0000
15@@ -445,7 +445,7 @@
16 def test_gets_relations(self, relation_get, related_units,
17 relation_ids, relation_types, local_unit):
18 local_unit.return_value = 'u0'
19- relation_types.return_value = ['t1','t2']
20+ relation_types.return_value = ['t1', 't2']
21 relation_ids.return_value = ['i1']
22 related_units.return_value = ['u1', 'u2']
23 relation_get.return_value = {'key': 'val'}
24@@ -507,8 +507,8 @@
25 @patch('charmhelpers.core.hookenv.relation_get')
26 @patch('charmhelpers.core.hookenv.os')
27 def test_gets_execution_environment_no_relation(
28- self, os_, relations_get, relations, relation_id,
29- local_unit, relation_type, config):
30+ self, os_, relations_get, relations, relation_id,
31+ local_unit, relation_type, config):
32 config.return_value = 'some-config'
33 relation_type.return_value = 'some-type'
34 local_unit.return_value = 'some-unit'
35@@ -526,7 +526,6 @@
36 'env': 'some-environment',
37 })
38
39-
40 @patch('charmhelpers.core.hookenv.os')
41 def test_gets_the_relation_id(self, os_):
42 os_.environ = {
43@@ -618,7 +617,7 @@
44 def test_sets_relation_with_relation_id(self, check_call_):
45 hookenv.relation_set(relation_id="foo", bar="baz")
46 check_call_.assert_called_with(['relation-set', '-r', 'foo',
47- 'bar=baz'])
48+ 'bar=baz'])
49
50 @patch('subprocess.check_call')
51 def test_sets_relation_with_missing_value(self, check_call_):
52@@ -639,10 +638,11 @@
53 hookenv.open_port(443, "TCP")
54 hookenv.open_port(80)
55 hookenv.open_port(100, "UDP")
56- calls = [call(['open-port', '443/TCP']),
57- call(['open-port', '80/TCP']),
58- call(['open-port', '100/UDP']),
59- ]
60+ calls = [
61+ call(['open-port', '443/TCP']),
62+ call(['open-port', '80/TCP']),
63+ call(['open-port', '100/UDP']),
64+ ]
65 check_call_.assert_has_calls(calls)
66
67 @patch('subprocess.check_call')
68@@ -650,10 +650,11 @@
69 hookenv.close_port(443, "TCP")
70 hookenv.close_port(80)
71 hookenv.close_port(100, "UDP")
72- calls = [call(['close-port', '443/TCP']),
73- call(['close-port', '80/TCP']),
74- call(['close-port', '100/UDP']),
75- ]
76+ calls = [
77+ call(['close-port', '443/TCP']),
78+ call(['close-port', '80/TCP']),
79+ call(['close-port', '100/UDP']),
80+ ]
81 check_call_.assert_has_calls(calls)
82
83 @patch('subprocess.check_output')
84
85=== modified file 'tests/payload/test_execd.py'
86--- tests/payload/test_execd.py 2013-06-11 14:15:03 +0000
87+++ tests/payload/test_execd.py 2013-07-11 08:33:31 +0000
88@@ -18,7 +18,7 @@
89 self.test_charm_dir = charm_dir
90
91 env_patcher = patch.dict('os.environ',
92- {'CHARM_DIR': self.test_charm_dir})
93+ {'CHARM_DIR': self.test_charm_dir})
94 env_patcher.start()
95 self.addCleanup(env_patcher.stop)
96
97@@ -31,11 +31,11 @@
98 def make_preinstall_executable(self, module_dir, execd_dir='exec.d',
99 error_on_preinstall=False):
100 """Add a charm-pre-install to module dir.
101-
102+
103 When executed, the charm-pre-install will create a second
104 file in the same directory, charm-pre-install-success.
105 """
106- module_path = os.path.join(self.test_charm_dir, execd_dir, module_dir)
107+ module_path = os.path.join(self.test_charm_dir, execd_dir, module_dir)
108 os.makedirs(module_path)
109
110 charm_pre_install_path = os.path.join(module_path,
111@@ -44,7 +44,7 @@
112 'charm-pre-install-success')
113 with open(charm_pre_install_path, 'w+') as f:
114 f.write("#!/bin/bash\n"
115- "/usr/bin/touch {}".format(pre_install_success_path))
116+ "/usr/bin/touch {}".format(pre_install_success_path))
117 perms = stat.S_IXUSR
118 # If the charm-pre-install should run without errors,
119 # ensure it is executable.
120@@ -113,7 +113,6 @@
121 'charm-pre-install') for mod in modules]
122 self.assertItemsEqual(submodules, expected)
123
124-
125 def test_execd_run(self):
126 modules = ['basenode', 'mod2', 'c']
127 for module in modules:
128@@ -138,10 +137,9 @@
129 self.test_charm_dir))
130 log_.assert_called_with(expected_log)
131
132-
133 @patch('charmhelpers.core.hookenv.log')
134 @patch('sys.exit')
135- def test_execd_run_dies_with_return_code(self, exit_, log_):
136+ def test_execd_run_dies_with_return_code(self, exit_, log):
137 self.make_preinstall_executable(module_dir='basenode',
138 error_on_preinstall=True)
139

Subscribers

People subscribed via source and target branches