Catching a bare Exception is bad form, can you be more specific? The original caught OSError.
[2]
56 + raise PowerActionFail(self, e)
57 + # This output is only examined in tests, execute just ignores it
58 + return output
You've changed this from a PIPE to using the parent's FDs. I wrote the original code and although I can't remember why I used a PIPE I am pretty sure I had a good reason, so I reckon you should change it back to PIPE. I have a sneaking suspicion that some of the scripts caused a hang or something weird in the output from the celery process.
I should have added a comment about it :/
[3]
Our coding standards say to add a line break immediately after an opening parenthesis, so can you fix the following bits please:
86 + self.assertThat(lambda: pa.render_template(template),
87 + Raises(MatchesException(PowerActionFail,
88 + ".*name 'mac' is not defined at line \d+ column \d+ "
89 + "in file %s" % re.escape(template_name))))
Thanks for the branch Martin, a definite improvement. I am a little concerned about one of the changes in [2] below so marking needs-fixing for that.
Cheers.
[1]
53 + output = subprocess. check_output( subprocess. STDOUT, close_fds=True)
54 + commands, shell=True, stderr=
55 + except Exception as e:
Catching a bare Exception is bad form, can you be more specific? The original caught OSError.
[2]
56 + raise PowerActionFail (self, e)
57 + # This output is only examined in tests, execute just ignores it
58 + return output
You've changed this from a PIPE to using the parent's FDs. I wrote the original code and although I can't remember why I used a PIPE I am pretty sure I had a good reason, so I reckon you should change it back to PIPE. I have a sneaking suspicion that some of the scripts caused a hang or something weird in the output from the celery process.
I should have added a comment about it :/
[3]
Our coding standards say to add a line break immediately after an opening parenthesis, so can you fix the following bits please:
86 + self.assertThat (lambda: pa.render_ template( template) , MatchesExceptio n(PowerActionFa il, template_ name))) )
87 + Raises(
88 + ".*name 'mac' is not defined at line \d+ column \d+ "
89 + "in file %s" % re.escape(
snip....
95 def test_execute_ raises_ PowerActionFail _when_script_ fails(self) : template_ file("this_ is_not_ valid_shell" ) es(PowerActionF ail, self.run_action, path) (lambda: self.run_ action( path), MatchesExceptio n(PowerActionFa il, raises_ PowerActionFail _with_output( self): template_ file("echo reason for failure; exit 1") (lambda: self.run_ action( path), MatchesExceptio n(PowerActionFa il, ".*:\nreason for failure")))
96 path = self._create_
97 - exception = self.assertRais
98 - self.assertEqual(
99 - "ether_wake failed with return code 127", exception.message)
100 + self.assertThat
101 + Raises(
102 + "ether_wake failed.* return.* 127")))
103 +
104 + def test_execute_
105 + path = self._create_
106 + self.assertThat
107 + Raises(