1

I am using python-nose to run some tests. The test code is arranged into modules, where each module's fixtures install some VMs in a new configuration, and the module's tests then check the behaviour of those VMs is what is expected.

I want to install a per-module failure handler that goes off and grabs the logs from the VMs if any test in the module fails. Is there a proper way of doing that? Is there some callback you can register with python-nose which will kick off custom code when a test fails?

Thanks,

Alex Zeffertt
  • 1,462
  • 11
  • 12

1 Answers1

0

Sounds like you should write a plugin. You may be interested in defining afterTest(), handleFailure() methods on your Plugin class. Hope that helps.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks. I'm not sure I understand the idea. Do I simply create a subclass of `nose.plugins.base.Plugin` in the python module under test which contains a `handleFailure` method? Or is there something else I need to do to get `nosetests` to figure out that this is the action needed for tests that fail (in that python module)? – Alex Zeffertt Apr 06 '13 at 13:54
  • It doesn't look straightforward to me - but maybe I'm stupid. They give plenty examples and docs on how to write a plugin, but I can't find anything explaining how you actually get nosetests to offer the plugin. – Alex Zeffertt Apr 08 '13 at 09:01