def test2(self): self.assertFalse(module.os.path.exists(self.dir_path)) UtilsCommand.check_call( "make_sure_parent_dir_exists", self.dir_path + "/test1/test2", ) self.assertTrue(module.os.path.exists(self.dir_path)) self.assertTrue(module.os.path.exists(self.dir_path + "/test1"))
def test1(self): self.assertEqual(self.read(), "") result = UtilsCommand.check_call( "append_line_once", "test success", self.fp.name, ) self.assertEqual(result, "ok\n") self.assertEqual(self.read(), "test success\n") result = UtilsCommand.check_call( "append_line_once", "test success", self.fp.name, ) self.assertEqual(result, "skip\n") self.assertEqual(self.read(), "test success\n")
def test1(self): import re regex = re.compile(r'\x1b[^m]*m') result = UtilsCommand.check_call( "color_print", "this\nis\ntest\n", ) self.assertEqual("this\nis\ntest\n", regex.sub('', result)) result = UtilsCommand.check_call( "color_print", "this is test", "color=yellow", "mode=bg", "style=underline", ) self.assertEqual("this is test", regex.sub('', result))
def test1(self): self.assertEqual( UtilsCommand.check_call("path_join", "a", "b"), "a/b", ) self.assertEqual( UtilsCommand.check_call("path_join", "a/", "b"), "a/b", ) self.assertEqual( UtilsCommand.check_call("path_join", "a", "/b"), "a/b", ) self.assertEqual( UtilsCommand.check_call("path_join", "a/", "/b"), "a/b", ) self.assertEqual( UtilsCommand.check_call("path_join", "/", "/b"), "/b", ) self.assertEqual( UtilsCommand.check_call("path_join", "/", "/"), "/", ) self.assertEqual( UtilsCommand.check_call("path_join", "/", ""), "/", ) self.assertEqual( UtilsCommand.check_call("path_join", "", "b"), "/b", ) self.assertEqual( UtilsCommand.check_call("path_join", ".", "b"), "./b", )