Change in vdsm[master]: Test: regression test to catch cross imports.

gvallare at redhat.com gvallare at redhat.com
Fri May 3 07:43:56 UTC 2013


Giuseppe Vallarelli has posted comments on this change.

Change subject: Test: regression test to catch cross imports.
......................................................................


Patch Set 6: (3 inline comments)

....................................................
File tests/crossImportsTests.py
Line 25: from testrunner import VdsmTestCase as TestCaseBase
Line 26: 
Line 27: 
Line 28: def path_without_vdsm_ext_mod():
Line 29:     exp = '(\S*)/vdsm/(vdsm|client|vdsm_api)'
You're right it's a strong assumption which doesn't hold, I'll fix that, thanks for the feedback.
Line 30:     pattern = re.compile(exp)
Line 31:     new_path = list(it.ifilterfalse(
Line 32:                     lambda x: pattern.match(x), sys.path))
Line 33:     return new_path


Line 35: 
Line 36: class CrossImportsTestCaseShould(TestCaseBase):
Line 37: 
Line 38:     def test_fail_when_importing_ext_mod(self):
Line 39:         sys.path = path_without_vdsm_ext_mod()
Yes it is needed if the script is used in that way. Not in case it's used ./run_tests_local.sh *.py . It's a good idea to restore the path.
Line 40:         import_ext_mod = False
Line 41:         try:
Line 42:             __import__('vdsm', fromlist=['libvirtconnection', 'netinfo',
Line 43:                                          'vdscli'])


Line 39:         sys.path = path_without_vdsm_ext_mod()
Line 40:         import_ext_mod = False
Line 41:         try:
Line 42:             __import__('vdsm', fromlist=['libvirtconnection', 'netinfo',
Line 43:                                          'vdscli'])
I figured they are the most important ones, they depends on other modules in lib/vdsm as well. But it's not the best solution cause if a new module is added, should be added also in this list, which is error prone.
Line 44:         except ImportError:
Line 45:             import_ext_mod = True
Line 46:             e_type, e_value, e_tb = sys.exc_info()
Line 47:             msg = 'Fail due to: %s' % (''.join(fmt_exc(e_type, e_value, e_tb)))


--
To view, visit http://gerrit.ovirt.org/14311
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I46b293c34e5968d21097137f3d1076f4199a5fd7
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Giuseppe Vallarelli <gvallare at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Giuseppe Vallarelli <gvallare at redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list