Adding devel@ovirt, the proper mailing list

בתאריך יום ו׳, 24 בנוב׳ 2017, 7:42, מאת Germano Veit Michel ‏<germano@redhat.com>:
Hi,

I'm trying to write a test for a hook. The test will fail if the hook does "import hooking", which seems to be the norm for vdsm hooks.

[vdsm_hooks]$ grep -rn "import hooking" | wc -l
55

Not sure if I'm doing something wrong, but it looks like I would need vdsm installed on my development machine in order for this import to work.

======================================================================
ERROR: test suite for <class 'virttests.boot_hostdev_test.BootHostdevHookTests'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/suite.py", line 209, in run
    self.setUp()
  File "/usr/lib/python2.7/site-packages/nose/suite.py", line 292, in setUp
    self.setupContext(ancestor)
  File "/usr/lib/python2.7/site-packages/nose/suite.py", line 315, in setupContext
    try_run(context, names)
  File "/usr/lib/python2.7/site-packages/nose/util.py", line 471, in try_run
    return func()
  File "/home/gveitmic/Source/upstream/vdsm/tests/virttests/boot_hostdev_test.py", line 127, in setUpClass
    import before_vm_start as boot_hostdev_hook
  File "../vdsm_hooks/boot_hostdev/before_vm_start.py", line 24, in <module>
    import hooking
ImportError: No module named hooking

I can make it go away by using this in my hook:

from vdsm.hook import hooking

Then the test succeeds fine. But then I see all hooks use "import hooking" instead of "from vdsm.hook import hooking".

[vdsm_hooks]$ grep -rn "from vdsm.hook import hooking" | wc -l
0

Am I doing something wrong? Can someone put a light here? What is the correct way to do this import?

Thanks,
Germano