import unittest import sh class Qnand(unittest.TestCase): params = None __device = "10M" # varlist: device def __init__(self, testname, testfunc, varlist): self.params = varlist super(Qnand, self).__init__(testfunc) if "device" in varlist: self.__device = varlist["device"] else: raise Exception('device param inside Qnand must be defined') self._testMethodDoc = testname def execute(self): try: p = sh.nandtest("-m", self.__device) # save result with open('/tmp/nand-nandtest.txt', 'w') as outfile: n = outfile.write(p.stdout.decode('ascii')) except sh.ErrorReturnCode as e: self.fail("failed: could not complete nandtest command") def getresults(self): # resultlist is a python list of python dictionaries resultlist = [ { "desc": "nandtest output", "data": "/tmp/nand-nandtest.txt", "type": "file" } ] return resultlist