Changeset 94127 in vbox
- Timestamp:
- Mar 8, 2022 2:44:28 PM (3 years ago)
- Location:
- trunk/src/VBox/ValidationKit/tests
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddBasic1.py
r93734 r94127 142 142 % (uuid.uuid4(), self.sVBoxValidationKitIso, sGaIso); 143 143 reporter.log2('Using VISO combining ValKit and GAs "%s": %s' % (sVisoContent, sGaViso)); 144 oGaViso = open(sGaViso, 'w'); 145 oGaViso.write(sVisoContent); 146 oGaViso.close(); 144 with open(sGaViso, 'w') as oGaViso: 145 oGaViso.write(sVisoContent); 147 146 sGaIso = sGaViso; 148 147 -
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r93889 r94127 151 151 sHstFileName = os.path.join(oTstDrv.sScratchPath, sFileName); 152 152 try: 153 oCurTestFile = open(sHstFileName, "wb"); 154 oCurTestFile.write(aData); 155 oCurTestFile.close(); 153 with open(sHstFileName, "wb") as oCurTestFile: 154 oCurTestFile.write(aData); 156 155 except: 157 156 return reporter.error('Unable to create temporary file for "%s"' % (sDesc,)); … … 1772 1771 sDst = os.path.join(sDst, oTest.oSrc.sName); 1773 1772 try: 1774 oFile = open(sDst, 'rb'); 1773 oFile = open(sDst, 'rb'); # pylint: disable=consider-using-with 1775 1774 except: 1776 1775 return reporter.errorXcpt('open(%s) failed during verfication' % (sDst,)); … … 1811 1810 sFilePath = os.path.join(sHostPath, oFsObj.sName); 1812 1811 try: 1813 oFile = open(sFilePath, 'rb'); 1812 oFile = open(sFilePath, 'rb'); # pylint: disable=consider-using-with 1814 1813 except: 1815 1814 fRc = reporter.errorXcpt('open(%s) failed during verfication' % (sFilePath,)); … … 4030 4029 return (False, oTxsSession); 4031 4030 4032 for sPath in self.oTestFiles.dPaths: 4033 oFsObj = self.oTestFiles.dPaths[sPath]; 4031 for oFsObj in self.oTestFiles.dPaths.values(): 4034 4032 reporter.log2('testGuestCtrlFileStat: %s sPath=%s' 4035 4033 % ('file' if isinstance(oFsObj, testfileset.TestFile) else 'dir ', limitString(oFsObj.sPath),)); … … 4696 4694 def __generateFile(sName, cbFile): 4697 4695 """ Helper for generating a file with a given size. """ 4698 oFile = open(sName, 'wb');4699 while cbFile > 0:4700 cb = cbFile if cbFile < 256*1024 else 256*1024;4701 oFile.write(bytearray(random.getrandbits(8) for _ in xrange(cb)));4702 cbFile -= cb;4703 oFile.close();4696 with open(sName, 'wb') as oFile: 4697 while cbFile > 0: 4698 cb = cbFile if cbFile < 256*1024 else 256*1024; 4699 oFile.write(bytearray(random.getrandbits(8) for _ in xrange(cb))); 4700 cbFile -= cb; 4701 return True; 4704 4702 4705 4703 def testGuestCtrlCopyTo(self, oSession, oTxsSession, oTestVm): # pylint: disable=too-many-locals … … 4770 4768 sEmptyFileHst = os.path.join(self.oTstDrv.sScratchPath, 'gctrl-empty.data'); 4771 4769 try: 4772 oFile = open(sEmptyFileHst, "wb"); 4773 oFile.close(); 4770 open(sEmptyFileHst, "wb").close(); # pylint: disable=consider-using-with 4774 4771 except: 4775 4772 return reporter.errorXcpt('sEmptyFileHst=%s' % (sEmptyFileHst,)); -
trunk/src/VBox/ValidationKit/tests/api/tdAppliance1.py
r93115 r94127 161 161 try: 162 162 os.mkdir(sTmpDir, 0o755); 163 oTarFile = tarfile.open(sOva, 'r:*'); 163 oTarFile = tarfile.open(sOva, 'r:*'); # No 'with' support in 2.6. pylint: disable=consider-using-with 164 164 oTarFile.extractall(sTmpDir); 165 165 oTarFile.close(); -
trunk/src/VBox/ValidationKit/tests/api/tdMoveVm1.py
r93115 r94127 397 397 fRc = self.oTstDrv.terminateVmBySession(oSession) 398 398 399 if fRc is True or False:399 if fRc is True: 400 400 # Create a new Session object for moving VM. 401 401 oSession = self.oTstDrv.openSession(oMachine) -
trunk/src/VBox/ValidationKit/tests/serial/loopback.py
r93115 r94127 224 224 Shutdown any connection and wait for it to become idle. 225 225 """ 226 self.oLock.acquire(); 227 self.fShutdown = True; 228 self.oLock.release(); 226 with self.oLock: 227 self.fShutdown = True; 229 228 self.oIoPumper.shutdown(); 230 229 … … 233 232 Returns whether the I/O pumping thread should shut down. 234 233 """ 235 self.oLock.acquire(); 236 fShutdown = self.fShutdown; 237 self.oLock.release(); 234 with self.oLock: 235 fShutdown = self.fShutdown; 238 236 239 237 return fShutdown; -
trunk/src/VBox/ValidationKit/tests/serial/tdSerial1.py
r93115 r94127 230 230 cLast = 0; 231 231 try: 232 oFile = open(self.sLocation, 'rb'); 233 sFmt = '=I'; 234 cBytes = 4; 235 for i in xrange(1048576 // 4): 236 _ = i; 237 sData = oFile.read(cBytes); 238 tupUnpacked = struct.unpack(sFmt, sData); 239 cLast = cLast + 1; 240 if tupUnpacked[0] != cLast: 241 reporter.testFailure('Corruption detected, expected counter value %s, got %s' 242 % (cLast + 1, tupUnpacked[0])); 243 break; 244 oFile.close(); 232 with open(self.sLocation, 'rb') as oFile: 233 sFmt = '=I'; 234 cBytes = 4; 235 for i in xrange(1048576 // 4): 236 _ = i; 237 sData = oFile.read(cBytes); 238 tupUnpacked = struct.unpack(sFmt, sData); 239 cLast = cLast + 1; 240 if tupUnpacked[0] != cLast: 241 reporter.testFailure('Corruption detected, expected counter value %s, got %s' 242 % (cLast + 1, tupUnpacked[0],)); 243 break; 245 244 except: 246 245 reporter.logXcpt(); -
trunk/src/VBox/ValidationKit/tests/storage/remoteexecutor.py
r93115 r94127 243 243 sFileId = self.sScratchPath + '/' + sFilename; 244 244 try: 245 oFile = open(sFileId, 'wb'); 246 oFile.write(sContent); 247 oFile.close(); 245 with open(sFileId, 'wb') as oFile: 246 oFile.write(sContent); 248 247 except: 249 248 sFileId = None; -
trunk/src/VBox/ValidationKit/tests/unittests/tdUnitTest1.py
r93904 r94127 1051 1051 # Open /dev/null for use as stdin further down. 1052 1052 try: 1053 oDevNull = open(os.path.devnull, 'w+'); 1053 oDevNull = open(os.path.devnull, 'w+'); # pylint: disable=consider-using-with 1054 1054 except: 1055 1055 oDevNull = None; -
trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py
r93115 r94127 36 36 sys.path.insert(0, '..'); 37 37 sys.path.insert(0, '../..'); 38 from common import utils; 39 from testdriver import reporter; 38 40 import usbgadget; 39 import testdriver.reporter as reporter40 from common import utils;41 41 42 42
Note:
See TracChangeset
for help on using the changeset viewer.