def testIsotopicMassesTokenNotMatching(self): # fold>> data = FileSnippets.isotopicMasses() writeToTestFile("\n" + data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.IsotopicMassesToken.match(reader) self.assertEqual(token, None) self.assertEqual(reader.currentPos(), start_pos)
def testFileHeaderToken(self): # fold>> data = FileSnippets.fileHeader() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.FileHeaderToken.match(reader) self.assertEqual(token.__class__, Tokens.FileHeaderToken) self.assertEqual(reader.currentPos(), start_pos + 1)
def tokenize(self, filename): reader = FileReader.FileReader(filename) token_list = [] while not reader.isAtEOF(): token = self._resolveNextToken(reader) if token is None: reader.readline() else: token_list.append(token) return token_list
def testEmptyFileSeeks(self): # fold>> f = FileReader.FileReader( os.path.join(moduleDir(), "emptytestfile.txt")) self.assertEqual(f.currentPos(), -1) self.assertEqual(f.isAtBOF(), True) f.toEOF() self.assertEqual(f.currentPos(), 0) self.assertEqual(f.isAtEOF(), True) f.toBOF() self.assertEqual(f.currentPos(), -1) self.assertEqual(f.isAtBOF(), True)
def testSkipLines(self): # fold>> "Seeking with relative jumps" f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) self.assertEqual(f.currentPos(), -1) f.skipLines(3) self.assertEqual(f.currentPos(), 2) f.skipLines(-1) self.assertEqual(f.currentPos(), 1) f.skipLines(10) self.assertEqual(f.isAtEOF(), True) f.skipLines(-10) self.assertEqual(f.isAtBOF(), True)
def testTotalMassToken(self): # fold>> data = FileSnippets.totalMass() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.TotalMassToken.match(reader) self.assertEqual(token.__class__, Tokens.TotalMassToken) self.assertEqual(reader.currentPos(), start_pos + 1) self.assertEqual(type(token.totalMass()), type("")) self.assertEqual(token.totalMass(), "30.010565")
def testFileReadlineBackward(self): # fold>> f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) f.toEOF() l = f.readbackline() self.assertEqual(l, "3rd line\n") l = f.readbackline() self.assertEqual(l, "2nd line\n") l = f.readbackline() self.assertEqual(l, "1st line\n") # now the pointer is at begin of file self.assertEqual(f.readbackline(), '')
def testFileReadLine(self): # fold>> f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) l = f.readline() self.assertEqual(l, "1st line\n") l = f.readline() self.assertEqual(l, "2nd line\n") l = f.readline() self.assertEqual(l, "3rd line\n") # now the pointer is at end of file self.assertEqual(f.readline(), '') f.close()
def testOccurrences(self): # fold>> "Seeking with relative jumps" f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) f.skipLines(1) self.assertEqual(f.isAtPos(0), True) self.assertEqual(f.occurrences('line'), [1, 2]) self.assertEqual(f.isAtPos(0), True) f.skipLines(2) self.assertEqual(f.isAtPos(2), True) self.assertEqual(f.occurrences('line', backward=True), [1, 0]) self.assertEqual(f.isAtPos(2), True) f.toBOF() self.assertEqual(f.occurrences('not found'), [])
def testDipoleMomentToken(self): # fold>> data = FileSnippets.dipoleMoment() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.DipoleMomentToken.match(reader) self.assertEqual(token.__class__, Tokens.DipoleMomentToken) self.assertEqual(reader.currentPos(), start_pos + 4) dipole = token.dipole() self.assertAlmostEqual(dipole, 3.141592)
def testFinalGeometryEnergyToken(self): # fold>> data = FileSnippets.finalGeometryEnergy() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.FinalGeometryEnergyToken.match(reader) self.assertEqual(token.__class__, Tokens.FinalGeometryEnergyToken) self.assertEqual(reader.currentPos(), start_pos + 1) energy = token.energy() self.assertEqual(type(energy), type("")) self.assertEqual(energy, "-113.984888")
def testEmptyFileGetItemOutOfBounds(self): # fold>> f = FileReader.FileReader( os.path.join(moduleDir(), "emptytestfile.txt")) # move at BOF with big negative num self.assertEqual(f[-999999], '') self.assertEqual(f.isAtBOF(), True) # move at EOF with big positive num self.assertEqual(f[9999999], '') self.assertEqual(f.isAtEOF(), True) # move at BOF with -1 self.assertEqual(f[-1], '') self.assertEqual(f.isAtBOF(), True) # move at EOF with len self.assertEqual(f[len(f)], '') self.assertEqual(f.isAtEOF(), True)
def testGeometryConvergenceNumIterationsToken(self): # fold>> data = FileSnippets.geometryConvergenceNumIterations() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.GeometryConvergenceNumIterationsToken.match(reader) self.assertEqual(token.__class__, Tokens.GeometryConvergenceNumIterationsToken) self.assertEqual(reader.currentPos(), start_pos + 1) iterations = token.iterations() self.assertEqual(type(iterations), type(1)) self.assertEqual(iterations, 8)
def testDipoleMomentsComponents(self): # fold>> data = FileSnippets.dipoleMomentComponents() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.DipoleMomentComponentsToken.match(reader) self.assertEqual(token.__class__, Tokens.DipoleMomentComponentsToken) self.assertEqual(reader.currentPos(), start_pos + 8) dipole = token.dipole() self.assertAlmostEqual(dipole[0], 3.14159270) self.assertAlmostEqual(dipole[1], -1.23456789) self.assertAlmostEqual(dipole[2], 9.87654321)
def testCenterOfMassToken(self): # fold>> data = FileSnippets.centerOfMass() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.CenterOfMassToken.match(reader) self.assertEqual(token.__class__, Tokens.CenterOfMassToken) self.assertEqual(reader.currentPos(), start_pos + 1) self.assertEqual(type(token.centerOfMass()), type(())) self.assertEqual(len(token.centerOfMass()), 3) self.assertEqual(token.centerOfMass()[0], "0.000000") self.assertEqual(token.centerOfMass()[1], "1.000000") self.assertEqual(token.centerOfMass()[2], "1.223609")
def testNormalModesEigenvaluesToken(self): # fold>> data = FileSnippets.normalModesEigenvalues() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.NormalModesEigenvaluesToken.match(reader) self.assertEqual(token.__class__, Tokens.NormalModesEigenvaluesToken) self.assertEqual(reader.currentPos(), start_pos + 10) self.assertEqual(len(token.values()), 6) for index, correct_value in enumerate([ 1.279649E-42, 1.279649E-42, 4.094095E-04, 9.790871E-44, 9.790871E-44, -1.212226E-21 ]): self.assertAlmostEqual(token.values()[index], correct_value)
def testIsotopicMassesToken(self): # fold>> data = FileSnippets.isotopicMasses() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.IsotopicMassesToken.match(reader) self.assertEqual(token.__class__, Tokens.IsotopicMassesToken) self.assertEqual(reader.currentPos(), start_pos + 8) atom_list = token.atomList() self.assertEqual(type(atom_list), type([])) self.assertEqual(len(atom_list), 4) self.assertEqual(atom_list[0], ("O1", "", "15.994915")) self.assertEqual(atom_list[1], ("H1", "1", "1.007825")) self.assertEqual(atom_list[2], ("H1", "2", "1.007825")) self.assertEqual(atom_list[3], ("C1", "", "12.000000"))
def testOptimizationInfoToken2(self): # fold>> data = FileSnippets.optimizationInfo2() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.OptimizationInfoToken.match(reader) self.assertEqual(token.__class__, Tokens.OptimizationInfoToken) self.assertEqual(reader.currentPos(), start_pos + 11) self.assertEqual(token.iteration(), 1) self.assertEqual(token.endOfOptimization(), True) self.assertEqual(token.energy(), "-113.984495") self.assertEqual(token.energyChange(), "-0.051859") self.assertEqual(token.gradientNorm(), "0.030306") self.assertEqual(token.stepNorm(), "0.030552") self.assertEqual(token.trustRadius(), "0.584403") self.assertEqual(token.totalHessianIndex(), 0)
def testOptimizationInfoToken(self): # fold>> data = FileSnippets.optimizationInfo() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.OptimizationInfoToken.match(reader) self.assertEqual(token.__class__, Tokens.OptimizationInfoToken) self.assertEqual(reader.currentPos(), start_pos + 10) self.assertEqual(token.iteration(), 0) self.assertEqual(token.endOfOptimization(), False) self.assertEqual(token.energy(), "-113.932636") self.assertEqual(token.energyChange(), None) self.assertEqual(token.gradientNorm(), "0.567825") self.assertEqual(token.stepNorm(), "0.487002") self.assertEqual(token.trustRadius(), "0.500000") self.assertEqual(token.totalHessianIndex(), 0)
def testAtomsAndBasisSetsToken(self): # fold>> data = FileSnippets.atomsAndBasisSetsTable() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.AtomsAndBasisSetsToken.match(reader) self.assertEqual(token.__class__, Tokens.AtomsAndBasisSetsToken) self.assertEqual(reader.currentPos(), start_pos + 22) self.assertEqual(token.totalNumberOfAtoms(), 10) self.assertEqual(token.numOfAtomTypes(), 2) self.assertEqual(len(token.atomDataList()), 10) self.assertEqual(token.atomDataList()[0][0], "H1") self.assertEqual(token.atomDataList()[0][1], 1) self.assertEqual(token.atomDataList()[0][2], 1) self.assertEqual(token.atomDataList()[0][3], 7) self.assertEqual(token.atomDataList()[0][4], 5) self.assertEqual(token.atomDataList()[0][5], "[4s1p|2s1p]") self.assertEqual(token.atomDataList()[5][0], "H6") self.assertEqual(token.atomDataList()[5][1], 1) self.assertEqual(token.atomDataList()[5][2], 1) self.assertEqual(token.atomDataList()[5][3], 7) self.assertEqual(token.atomDataList()[5][4], 5) self.assertEqual(token.atomDataList()[5][5], "[4s1p|2s1p]") self.assertEqual(token.atomDataList()[6][0], "C1") self.assertEqual(token.atomDataList()[6][1], 1) self.assertEqual(token.atomDataList()[6][2], 6) self.assertEqual(token.atomDataList()[6][3], 26) self.assertEqual(token.atomDataList()[6][4], 14) self.assertEqual(token.atomDataList()[6][5], "[9s4p1d|3s2p1d]") self.assertEqual(token.atomDataList()[9][0], "C4") self.assertEqual(token.atomDataList()[9][1], 1) self.assertEqual(token.atomDataList()[9][2], 6) self.assertEqual(token.atomDataList()[9][3], 26) self.assertEqual(token.atomDataList()[9][4], 14) self.assertEqual(token.atomDataList()[9][5], "[9s4p1d|3s2p1d]")
def testMomentsOfInertiaToken(self): # fold>> data = FileSnippets.momentsOfInertia() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.MomentsOfInertiaToken.match(reader) self.assertEqual(token.__class__, Tokens.MomentsOfInertiaToken) self.assertEqual(reader.currentPos(), start_pos + 7) moments = token.momentsOfInertia() self.assertEqual(moments[0], "1.747844") self.assertEqual(moments[1], "13.208584") self.assertEqual(moments[2], "14.956428") principal_axes = token.principalAxes() for i, j in [(0, 0), (0, 1), (1, 0), (1, 2), (2, 1), (2, 2)]: self.assertEqual(principal_axes[i][j], "0.000000") for i, j in [(0, 2), (1, 1), (0, 2)]: self.assertEqual(principal_axes[i][j], "1.000000")
def testHOMOLUMOSeparationToken(self): # fold>> data = FileSnippets.HomoLumoSeparation() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.HOMOLUMOSeparationToken.match(reader) self.assertEqual(token.__class__, Tokens.HOMOLUMOSeparationToken) self.assertEqual(reader.currentPos(), start_pos + 4) lumo_energy = token.LUMOEnergy() homo_energy = token.HOMOEnergy() lumo_symmetry = token.LUMOSymmetry() homo_symmetry = token.HOMOSymmetry() gap = token.gap() self.assertAlmostEqual(lumo_energy, 0.01936070) self.assertEqual(lumo_symmetry, 1) self.assertEqual(homo_symmetry, 1) self.assertAlmostEqual(homo_energy, -0.28830940) self.assertAlmostEqual(gap, 0.30767010)
def testBondLengthsToken(self): # fold>> data = FileSnippets.bondLengths() writeToTestFile(data) reader = FileReader.FileReader(testFilePath()) start_pos = reader.currentPos() token = Tokens.BondLengthsToken.match(reader) self.assertEqual(token.__class__, Tokens.BondLengthsToken) self.assertEqual(reader.currentPos(), start_pos + 15) self.assertEqual(len(token.atomList()), 9) self.assertEqual(token.atomList()[0][0][0], "C2") self.assertEqual(token.atomList()[0][0][1], "1") self.assertEqual(token.atomList()[0][1][0], "H1") self.assertEqual(token.atomList()[0][1][1], "1") self.assertEqual(token.atomList()[0][2], "1.091176") self.assertEqual(token.atomList()[8][0][0], "C4") self.assertEqual(token.atomList()[8][0][1], "2") self.assertEqual(token.atomList()[8][1][0], "C4") self.assertEqual(token.atomList()[8][1][1], "1") self.assertEqual(token.atomList()[8][2], "1.460430")
def testParseBasisSection(self): # fold>> filename = os.path.join(moduleDir(), "HSO2POEtg3.zmat") f = FileReader.FileReader(filename) zmat = [('O', '1'), ('C', '2', '1', '1.19576559'), ('C', '3', '2', '1.53312447', '1', '118.33351953'), ('S', '4', '3', '1.80206569', '2', '111.78682756', '1', '75.67592699'), ('P', '5', '3', '1.8448968', '2', '111.57603219', '4', '-128.40691686'), ('H', '6', '3', '1.08199628', '2', '111.51694325', '4', '113.3724925'), ('C', '7', '4', '1.76839634', '3', '108.02130357', '2', '-62.30804556'), ('H', '8', '7', '1.07858004', '4', '109.3110954', '3', '62.46718009'), ('H', '9', '7', '1.08259096', '4', '104.79349303', '8', '118.66525397'), ('H', '10', '7', '1.07869792', '4', '109.13117206', '8', '-121.94534813'), ('C', '11', '2', '1.48957644', '1', '121.74447654', '3', '-177.95494878'), ('C', '12', '11', '1.39340179', '2', '117.41320957', '1', '21.21675983'), ('C', '13', '11', '1.39044518', '2', '122.97326956', '12', '-178.44654244'), ('C', '14', '12', '1.38054101', '11', '120.26266887', '2', '-179.79472963'), ('C', '15', '13', '1.38471258', '11', '120.01221455', '2', '178.86904242'), ('C', '16', '14', '1.38765396', '12', '119.84605838', '11', '1.05496966'), ('H', '17', '12', '1.07358923', '11', '119.05794639', '14', '-179.76567536'), ('H', '18', '13', '1.07323301', '11', '120.82810526', '15', '-177.24354928'), ('H', '19', '14', '1.07512119', '12', '119.9917391', '16', '179.73244443'), ('H', '20', '15', '1.07486465', '13', '119.72327648', '11', '-179.11647443'), ('H', '21', '16', '1.07568689', '14', '119.90669975', '12', '179.68183354'), ('O', '22', '4', '1.43815155', '3', '105.58712546', '7', '116.05379021'), ('O', '23', '4', '1.43879487', '3', '105.92258212', '7', '-116.43966678'), ('O', '24', '5', '1.45504444', '3', '115.24875957', '2', '87.05344984'), ('O', '25', '5', '1.57337162', '3', '101.05663993', '24', '-126.17156573'), ('O', '26', '5', '1.56849371', '3', '103.4496195', '24', '127.71831196'), ('C', '27', '25', '1.42894607', '5', '122.33914213', '3', '124.70856793'), ('C', '28', '26', '1.43261165', '5', '123.98317478', '3', '-109.45854506'), ('C', '29', '27', '1.54', '25', '109.86517848', '5', '67.71385394'), ('H', '30', '27', '1.07949168', '25', '110.12220894', '29', '-121.59454892'), ('H', '31', '27', '1.0787856', '25', '105.9007008', '29', '119.03753102'), ('C', '32', '28', '1.54', '26', '106.016903', '5', '-155.75576458'), ('H', '33', '28', '1.07811168', '26', '109.22613503', '32', '-119.44715865'), ('H', '34', '28', '1.07960213', '26', '110.12358948', '32', '119.3672904'), ('H', '35', '29', '1.08', '27', '110.02', '25', '179.0'), ('H', '36', '29', '1.08', '27', '110.02', '35', '120.0'), ('H', '37', '29', '1.08', '27', '110.02', '35', '-120.0'), ('H', '38', '32', '1.08', '28', '110.02', '26', '179.0'), ('H', '39', '32', '1.08', '28', '110.02', '38', '120.0'), ('H', '40', '32', '1.08', '28', '110.02', '38', '-120.0')] basis = zmatmodule._parseBasisSection(f, zmat) valid_data = { 1: 'ziopeppe', 2: 'ziopeppe', 3: 'ziopeppe', 4: 'ziopeppe', 5: 'ziopeppe', 6: 'ziopeppe', 7: 'ziopeppe', 8: 'ziopeppe', 9: 'ziopeppe', 10: 'ziopeppe', 11: 'ziopeppe', 12: 'ziopeppe', 13: 'ziopeppe', 14: 'ziopeppe', 15: 'ziopeppe', 16: 'ziopeppe', 17: 'ziopeppe', 18: 'ziopeppe', 19: 'ziopeppe', 20: 'ziopeppe', 21: 'ziopeppe', 22: 'ziopeppe', 23: 'ziopeppe', 24: 'ziopeppe', 25: 'ziopeppe', 26: 'ziopeppe', 27: 'ziopeppe', 28: 'ziopeppe', 29: 'ziopeppe', 30: 'ziopeppe', 31: 'ziopeppe', 32: 'ziopeppe', 33: 'ziopeppe', 34: 'ziopeppe', 35: 'ziopeppe', 36: 'ziopeppe', 37: 'ziopeppe', 38: 'ziopeppe', 39: 'ziopeppe', 40: 'ziopeppe' } self.assertEqual(len(basis.keys()), len(valid_data.keys())) for key, value in basis.items(): self.assertEqual(valid_data.has_key(key), True) self.assertEqual(valid_data[key], value) f.close()
def testParseParametersSection(self): # fold>> filename = os.path.join(moduleDir(), "HSO2POEtg3.zmat") f = FileReader.FileReader(filename) params = zmatmodule._parseParametersSection(f) valid_data = { 'R38': '1.08', 'R39': '1.08', 'R34': '1.07960213', 'R35': '1.08', 'R36': '1.08', 'R37': '1.08', 'R30': '1.07949168', 'R31': '1.0787856', 'R32': '1.54', 'R33': '1.07811168', 'R4': '1.80206569', 'R5': '1.8448968', 'R6': '1.08199628', 'R7': '1.76839634', 'R2': '1.19576559', 'R3': '1.53312447', 'R8': '1.07858004', 'R9': '1.08259096', 'R16': '1.38765396', 'R17': '1.07358923', 'R14': '1.38054101', 'R15': '1.38471258', 'R12': '1.39340179', 'R13': '1.39044518', 'R10': '1.07869792', 'R11': '1.48957644', 'R18': '1.07323301', 'R19': '1.07512119', 'A40': '110.02', 'D14': '-179.79472963', 'D15': '178.86904242', 'D16': '1.05496966', 'D17': '-179.76567536', 'D10': '-121.94534813', 'D11': '-177.95494878', 'D12': '21.21675983', 'D13': '-178.44654244', 'D18': '-177.24354928', 'D19': '179.73244443', 'A33': '109.22613503', 'A32': '106.016903', 'A31': '105.9007008', 'A30': '110.12220894', 'A37': '110.02', 'A36': '110.02', 'A35': '110.02', 'A34': '110.12358948', 'A39': '110.02', 'A38': '110.02', 'D29': '67.71385394', 'D28': '-109.45854506', 'D21': '179.68183354', 'D20': '-179.11647443', 'D23': '-116.43966678', 'D22': '116.05379021', 'D25': '-126.17156573', 'D24': '87.05344984', 'D27': '124.70856793', 'D26': '127.71831196', 'A20': '119.72327648', 'A21': '119.90669975', 'A22': '105.58712546', 'A23': '105.92258212', 'A24': '115.24875957', 'A25': '101.05663993', 'A26': '103.4496195', 'A27': '122.33914213', 'A28': '123.98317478', 'A29': '109.86517848', 'R40': '1.08', 'D38': '179.0', 'D39': '120.0', 'D36': '120.0', 'D37': '-120.0', 'D34': '119.3672904', 'D35': '179.0', 'D32': '-155.75576458', 'D33': '-119.44715865', 'D30': '-121.59454892', 'D31': '119.03753102', 'A15': '120.01221455', 'A14': '120.26266887', 'A17': '119.05794639', 'A16': '119.84605838', 'A11': '121.74447654', 'A10': '109.13117206', 'A13': '122.97326956', 'A12': '117.41320957', 'A19': '119.9917391', 'A18': '120.82810526', 'A3': '118.33351953', 'A5': '111.57603219', 'A4': '111.78682756', 'A7': '108.02130357', 'A6': '111.51694325', 'A9': '104.79349303', 'A8': '109.3110954', 'R29': '1.54', 'R28': '1.43261165', 'R27': '1.42894607', 'R26': '1.56849371', 'D40': '-120.0', 'R25': '1.57337162', 'R24': '1.45504444', 'D8': '62.46718009', 'D9': '118.66525397', 'D6': '113.3724925', 'D7': '-62.30804556', 'D4': '75.67592699', 'D5': '-128.40691686', 'R23': '1.43879487', 'R22': '1.43815155', 'R21': '1.07568689', 'R20': '1.07486465' } self.assertEqual(len(params.keys()), len(valid_data.keys())) for key, value in params.items(): self.assertEqual(valid_data.has_key(key), True) self.assertEqual(valid_data[key], value) f.close()
def parseFile(self, infile): # fold>> self.__infile = FileReader.FileReader(infile) self.__parameters = _parseParametersSection(self.__infile) self.__zmatrix = _parseZMatrixSection(self.__infile, self.__parameters) self.__basis = _parseBasisSection(self.__infile, self.__zmatrix) self.__symmetries = _parseSymmetrySection(self.__infile)
def testCurrentPos(self): # fold>> f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) self.assertEqual(f.currentPos(), -1) f[1] self.assertEqual(f.currentPos(), 1)
def testCurrentLine(self): # fold>> f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) self.assertEqual(f.currentLine(), '') f[1] # now we're at line 1 self.assertEqual(f.currentLine(), "2nd line\n")
def testGetItemCurrentPos(self): # fold>> f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) l = f[2] self.assertEqual(f.currentPos(), 2)
def testLen(self): # fold>> f = FileReader.FileReader(os.path.join(moduleDir(), "testfile.txt")) self.assertEqual(len(f), 3) f.close()