Nir Soffer has posted comments on this change. Change subject: StorageDomainManifest: introduce class heirarchy ......................................................................
Patch Set 8: (5 comments) https://gerrit.ovirt.org/#/c/41993/8/tests/manifestTests.py File tests/manifestTests.py: Line 59: def setUp(self): Line 60: self.mountpoint = tempfile.mkdtemp(dir=TEMPDIR) Line 61: sdUUID = str(uuid.uuid4()) Line 62: self.domainPath = os.path.join(self.mountpoint, sdUUID) Line 63: self.manifest = fileSD.FileStorageDomainManifest(self.domainPath) If this fails, teardown will not be called. Line 64: Line 65: # Create a fake metadata file Line 66: metaDir = os.path.dirname(self.manifest.metafile) Line 67: os.makedirs(metaDir, 0o775) Line 63: self.manifest = fileSD.FileStorageDomainManifest(self.domainPath) Line 64: Line 65: # Create a fake metadata file Line 66: metaDir = os.path.dirname(self.manifest.metafile) Line 67: os.makedirs(metaDir, 0o775) If this fails, teardown will not be called. Line 68: open(self.manifest.metafile, "w").truncate(self.VOLSIZE * SDBLKSZ) Line 69: self.manifest.activate(fileSD.FileSDMetadata(self.manifest.metafile)) Line 70: Line 71: def tearDown(self): Line 64: Line 65: # Create a fake metadata file Line 66: metaDir = os.path.dirname(self.manifest.metafile) Line 67: os.makedirs(metaDir, 0o775) Line 68: open(self.manifest.metafile, "w").truncate(self.VOLSIZE * SDBLKSZ) If this fails, teardown will not be called. Line 69: self.manifest.activate(fileSD.FileSDMetadata(self.manifest.metafile)) Line 70: Line 71: def tearDown(self): Line 72: shutil.rmtree(self.mountpoint) Line 65: # Create a fake metadata file Line 66: metaDir = os.path.dirname(self.manifest.metafile) Line 67: os.makedirs(metaDir, 0o775) Line 68: open(self.manifest.metafile, "w").truncate(self.VOLSIZE * SDBLKSZ) Line 69: self.manifest.activate(fileSD.FileSDMetadata(self.manifest.metafile)) If this fails, teardown will not be called. Line 70: Line 71: def tearDown(self): Line 72: shutil.rmtree(self.mountpoint) Line 73: Line 71: def tearDown(self): Line 72: shutil.rmtree(self.mountpoint) Line 73: Line 74: def testGetReadDelay(self): Line 75: self.assertIsInstance(self.manifest.getReadDelay(), float) > Not sure I follow. I am doing more than simply creating a md file in order if setup fail in the middle, teardown will not be called: https://docs.python.org/2/library/unittest.html#unittest.TestCase.tearDown Sadly, this is true for all Python testing frameworks: - https://nose.readthedocs.org/en/latest/writing_tests.html#fixtures - https://pytest.org/latest/xunit_setup.html (see Note) If you want to use setup and teardown, you should catch all exceptions in setup, to make sure teardown always run, or you must cleanup errors in setup and re-raise. This is not practical, so it is better to use a context manager for setup and teardown. Line 76: Line 77: Line 78: class BlockManifestTests(TestCaseBase): Line 79: VOLSIZE = 1024 -- To view, visit https://gerrit.ovirt.org/41993 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia275424a8d423722efb229a4d8545f035fe5fa51 Gerrit-PatchSet: 8 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <[email protected]> Gerrit-Reviewer: Adam Litke <[email protected]> Gerrit-Reviewer: Ala Hino <[email protected]> Gerrit-Reviewer: Allon Mureinik <[email protected]> Gerrit-Reviewer: Dan Kenigsberg <[email protected]> Gerrit-Reviewer: Freddy Rolland <[email protected]> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Liron Aravot <[email protected]> Gerrit-Reviewer: Nir Soffer <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
