def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) pic = self.service["stve.picture"].get() self.assertTrue(self.get("system.tmp") != None) L.info(os.path.join(self.get("system.tmp"), "test01.png")) pic.info(pic.open(os.path.join(self.get("system.tmp"), "test01.png")))
def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) pic = self.service["stve.picture"].get() self.assertTrue(self.get("system.tmp") != None) reference = os.path.join(self.get("system.tmp"), "test01.png") target = os.path.join(self.get("system.tmp"), "test01_target01.png") point = pic.search_pattern(reference, target) self.assertTrue(point != None) L.info(point)
def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) pic = self.service["stve.picture"].get() self.assertTrue(self.get("system.tmp") != None) img = pic.open(os.path.join(self.get("system.tmp"), "test01.png")) self.assertTrue(img != None) rgb = pic.get_rgb(img) self.assertTrue(len(rgb) == 3) L.info(rgb)
def rm(self, filepath): if not type(filepath) in [str, unicode]: raise WorkspaceError("filepath must be strings.") if not os.path.exists(filepath): L.warning("it is not exists %s" % filepath) else: try: os.remove(filepath) return filepath except Exception as e: L.traceback() raise WorkspaceError("Can't remove file %s. Please Check File Permission." % filepath)
def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) pic = self.service["stve.picture"].get() self.assertTrue(self.get("system.tmp") != None) img = pic.open(os.path.join(self.get("system.tmp"), "test01.png")) self.assertTrue(img != None) binary_img = pic.binary(img) r,g,b = pic.get_rgb(binary_img) self.assertTrue(r == g) self.assertTrue(g == b) L.info("RGB (%s %s %s)" %(r, g, b))
def execute(self, script, host, v=2): if not os.path.exists(host): raise TestRunnerError("%s is not exists." % (host)) sys.path.append(host) suite = unittest.TestSuite() loader = unittest.TestLoader() module = self.load(script, host) if not module: L.warning("Not loaded module : %s" % script) raise TestRunnerError("%s is not extended StveTestCase." % script) else: suite.addTest(loader.loadTestsFromModule(module)) unittest.TextTestRunner(verbosity=v).run(suite)
def register(cls, host): if not os.path.exists(host): raise LibraryError("%s is not exists." % (host)) for fdn in os.listdir(host): try: if fdn.endswith(".pyc") or fdn.endswith(".py"): pass else: sys.path.append(os.path.join(host, fdn)) f, n, d = imp.find_module("service") module = imp.load_module("service", f, n, d) cls.service[module.NAME] = module.FACTORY sys.path.remove(os.path.join(host, fdn)) except Exception as e: L.warning(str(e))
def __init__(self, path, clear=False): if not type(path) in [str, unicode]: raise WorkspaceError("path must be strings.") self.default_path = os.path.abspath(path) if os.path.exists(path): if len(os.listdir(path)) > 0: L.warning("It is not vacant folder in the path.") if clear: try: for f in os.listdir(path): shutil.rmtree(os.path.join(path, f)) except Exception as e: L.traceback() raise WorkspaceError("it must be vacant folder in the path.") else: self._mkdir_recursive(self.default_path)
def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) pic = self.service["stve.picture"].get() self.assertTrue(self.get("system.tmp") != None) img = pic.open(os.path.join(self.get("system.tmp"), "test01.png")) self.assertTrue(img != None) opencv_img = pic.to_opencv(img) img2 = pic.to_pil(opencv_img) self.assertTrue(img2 != None) pic.save(img2, os.path.join(self.get("system.tmp"), "test02.png")) img3 = pic.open(os.path.join(self.get("system.tmp"), "test01.png")) self.assertTrue(img3 != None) L.info(pic.info(img3))
def execute_with_report(self, script, host, output): if not os.path.exists(host): raise TestRunnerError("%s is not exists." % (host)) sys.path.append(host) if not os.path.exists(output): raise TestRunnerError("%s is not exists." % (output)) suite = unittest.TestSuite() loader = unittest.TestLoader() module = self.load(script, host) if not module: L.warning("Not loaded module : %s" % script) raise TestRunnerError("%s is not extended StveTestCase." % script) else: suite.addTest(loader.loadTestsFromModule(module)) xmlrunner.XMLTestRunner(output=output).run(suite)
def load(self, testcase, host): if testcase.find(".py") != -1: script = testcase else: script = testcase + ".py" path = os.path.join(host, script) if not os.path.exists(path): raise TestRunnerError("%s is not exists." % (path)) name = script[:script.find(".")] L.debug("TestCase : %s" % path) try: if os.path.exists(path): f, n, d = imp.find_module(str(name)) return imp.load_module(name, f, n, d) else: return False except ImportError as e: L.traceback() return False
def mkdir(self, folder, host="", clear=False): if not type(folder) in [str, unicode]: raise WorkspaceError("folder must be strings.") if host == "": path = os.path.join(self.root(), folder) else: if not os.path.exists(host): self._mkdir_recursive(host) path = os.path.join(host, folder) if os.path.exists(path): if len(os.listdir(path)) > 0: L.warning("It is not vacant folder in the path.") if clear: try: for f in os.listdir(path): shutil.rmtree(os.path.join(path, f)) except Exception as e: L.traceback() raise WorkspaceError("it must be vacant folder in the path.") else: self._mkdir_recursive(path) return path
def rmdir(self, folder, host=""): if not type(folder) in [str, unicode]: raise WorkspaceError("folder must be strings.") if host == "": path = os.path.join(self.root(), folder) else: if not os.path.exists(host): L.warning("it is not exists %s" % host) return host path = os.path.join(host, folder) if not os.path.exists(path): L.warning("it is not exists %s" % path) return path else: try: shutil.rmtree(path); return path except Exception as e: L.traceback() raise WorkspaceError("Can't remove file %s. Please Check File Permission." % path)
def tearDownClass(cls): L.info("*** End TestCase : %s *** " % __file__)
def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) L.info(self.service["stve.picture"].version())
def setUpClass(cls): L.info("*** Start TestCase : %s *** " % __file__)
def test(self): self.assertTrue("stve.android" in self.service.keys()) self.assertTrue(self.service["stve.android"].version() != None) L.info(self.service["stve.android"].version())
def test(self): self.assertTrue("stve.picture" in self.service.keys()) self.assertTrue(self.service["stve.picture"].version() != None) L.info(self.service["stve.picture"].version()) pic = self.service["stve.picture"].get() self.assertTrue(pic != None)