示例#1
0
    def test0(self):
        displayNextTest(self)

        appRoutines.unitTestMode = True
        testutils_files.testx()
        with LogCapture() as cap:

            log.init_LogCapture()
            f = testutils_files.openCSVFile(self.fileRef)
            self.f = f
            self.assertIs(type(f), file,'open() function must return file object when file exists.')

            fd = csv.DictReader(f)
            print('- Column Headers:  %s' % fd.fieldnames)   # list of column header strings
            cap.clear()    # ignore previous logs
            self.assertTrue( set(parmTable.requiredColumnNames).issubset(fd.fieldnames),
                                msg='Required columns names missing.')
            row = next(fd)
            crow = parmTable.parmFileRec(row)
            print('row = %d  ID = "%s"' % (0, crow.id))
            #self.assertEqual(crow.url, row['ID'],msg='dict lookup and parmFileRec object agree on value')
            # same as assertEqual except displays the compared values on failure
            compare(crow.id, row['ID'],msg='dict lookup and parmFileRec object agree on value')

            print('Number of missing columns = %d  ' % crow.missingColumnsCnt)
            self.assertEqual('1', crow.id, msg='ID column does not contain correct value')
            print(cap)
            cap.check()    # no logs expected
 def test4_manualUsage(self):
     apptestutils.displayNextTest(self)
 def test3_decorator_techl(self):
     # only want to capture logging for the decorated test function
     apptestutils.displayNextTest(self)
 def test2_withMethod_userl(self):
     apptestutils.displayNextTest(self)