Change in vdsm[master]: Test: regression test to catch cross imports.
zhshzhou at linux.vnet.ibm.com
zhshzhou at linux.vnet.ibm.com
Fri May 3 04:15:00 UTC 2013
Zhou Zheng Sheng has posted comments on this change.
Change subject: Test: regression test to catch cross imports.
......................................................................
Patch Set 6: I would prefer that you didn't submit this
(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)'
This regex is assuming the developer use "vdsm" as the project source directory name. However, I use "vdsm-ubuntu" on my Ubuntu hosts and "vdsm-sheng" on my Fedora workstation. So this regex does not work for me.
I think a better way for determining a dir should be excluded is as follow.
subdirs = ['vdsm', 'client', 'vdsm_api']
excludeDirs = [os.path.abspath(os.path.join(os.path.dirname(__file__), '..', subdir)) for subdir in subdirs]
lambda x: os.path.abspath(x) in excludeDirs
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()
Does It need to restore the old sys.path? I see apiTests.py fails if it is run after test_fail_when_importing_ext_mod. apiTests.py needs API.py during the runtime.
./run_tests_local.sh crossImportsTests.py apiTests.py
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'])
Not all the modules under lib/vdsm are listed here, could you explain the reason?
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