def test_escape_path_argument_unsupported(self): _type = "INVALID" self.assertEqual(escape_path_argument("/home/usr/a-file", _type), "/home/usr/a-file") self.assertEqual( escape_path_argument("/home/us r/a-file with spaces.bla", _type), "/home/us r/a-file with spaces.bla") self.assertEqual( escape_path_argument("|home|us r|a*dir with spaces|x|", _type), "|home|us r|a*dir with spaces|x|") self.assertEqual(escape_path_argument("system|a|b|c?d", _type), "system|a|b|c?d")
def test_escape_path_argument_unsupported(self): _type = "INVALID" self.assertEqual( escape_path_argument("/home/usr/a-file", _type), "/home/usr/a-file") self.assertEqual( escape_path_argument("/home/us r/a-file with spaces.bla", _type), "/home/us r/a-file with spaces.bla") self.assertEqual( escape_path_argument("|home|us r|a*dir with spaces|x|", _type), "|home|us r|a*dir with spaces|x|") self.assertEqual( escape_path_argument("system|a|b|c?d", _type), "system|a|b|c?d")
def test_config_file_generator(self): self.uut.executable = "echo" self.uut.arguments = "-c {config_file}" self.assertEqual( self.uut._create_command(config_file="configfile").strip(), "echo -c " + escape_path_argument("configfile"))
def test_escape_path_argument_sh(self): _type = "sh" self.assertEqual(escape_path_argument("/home/usr/a-file", _type), "/home/usr/a-file") self.assertEqual(escape_path_argument("/home/usr/a-dir/", _type), "/home/usr/a-dir/") self.assertEqual( escape_path_argument("/home/us r/a-file with spaces.bla", _type), "'/home/us r/a-file with spaces.bla'") self.assertEqual( escape_path_argument("/home/us r/a-dir with spaces/x/", _type), "'/home/us r/a-dir with spaces/x/'") self.assertEqual( escape_path_argument( "relative something/with cherries and/pickles.delicious", _type), "'relative something/with cherries and/pickles.delicious'")
def test_escape_path_argument_cmd(self): _type = "cmd" self.assertEqual( escape_path_argument("C:\\Windows\\has-a-weird-shell.txt", _type), "\"C:\\Windows\\has-a-weird-shell.txt\"") self.assertEqual( escape_path_argument("C:\\Windows\\lolrofl\\dirs\\", _type), "\"C:\\Windows\\lolrofl\\dirs\\\"") self.assertEqual( escape_path_argument("X:\\Users\\Maito Gai\\fi le.exe", _type), "\"X:\\Users\\Maito Gai\\fi le.exe\"") self.assertEqual( escape_path_argument("X:\\Users\\Mai to Gai\\director y\\", _type), "\"X:\\Users\\Mai to Gai\\director y\\\"") self.assertEqual( escape_path_argument("X:\\Users\\Maito Gai\\\"seven-gates\".y", _type), "\"X:\\Users\\Maito Gai\\^\"seven-gates^\".y\"") self.assertEqual( escape_path_argument("System32\\my-custom relative tool\\", _type), "\"System32\\my-custom relative tool\\\"") self.assertEqual( escape_path_argument("System32\\illegal\" name \"\".curd", _type), "\"System32\\illegal^\" name ^\"^\".curd\"")
def test_escape_path_argument_sh(self): _type = "sh" self.assertEqual( escape_path_argument("/home/usr/a-file", _type), "/home/usr/a-file") self.assertEqual( escape_path_argument("/home/usr/a-dir/", _type), "/home/usr/a-dir/") self.assertEqual( escape_path_argument("/home/us r/a-file with spaces.bla", _type), "'/home/us r/a-file with spaces.bla'") self.assertEqual( escape_path_argument("/home/us r/a-dir with spaces/x/", _type), "'/home/us r/a-dir with spaces/x/'") self.assertEqual( escape_path_argument( "relative something/with cherries and/pickles.delicious", _type), "'relative something/with cherries and/pickles.delicious'")
def run(self, filename, file, perlcritic_profile: str = ""): ''' Checks the code with perlcritic. This will run perlcritic over each of the files seperately :param perlcritic_profile: Location of the perlcriticrc config file. ''' self.arguments = '--no-color --verbose "%l|%c|%s|%p|%m (%e)"' if perlcritic_profile: self.arguments += (" --profile " + escape_path_argument(perlcritic_profile)) self.arguments += " {filename}" return self.lint(filename)
def run(self, filename, file, xml_schema: path="", xml_dtd: path_or_url=""): ''' Checks the code with ``xmllint``. :param xml_schema: ``W3C XML Schema`` file used for validation. :param xml_dtd: ``Document type Definition (DTD)`` file or url used for validation. ''' self.arguments = "{filename} " if xml_schema: self.arguments += " -schema " + escape_path_argument(xml_schema) if xml_dtd: self.arguments += " -dtdvalid " + xml_dtd return self.lint(filename, file)
def run(self, filename, file, perlcritic_profile: str=""): ''' Checks the code with perlcritic. This will run perlcritic over each of the files seperately :param perlcritic_profile: Location of the perlcriticrc config file. ''' self.arguments = '--no-color --verbose "%l|%c|%s|%p|%m (%e)"' if perlcritic_profile: self.arguments += (" --profile " + escape_path_argument(perlcritic_profile)) self.arguments += " {filename}" return self.lint(filename)