def testInvalidFile(self): with self.assertRaises(SystemExit) as cm: parse_args(["-f", "440044.rq"]) self.assertEqual(cm.exception.code, 2) self.assertEqual( sys.stderr.getvalue().split("\n")[1], "rqw: error: argument -f/--file: file '440044.rq' is not found", )
def testInvalidFormat(self): with self.assertRaises(SystemExit) as cm: parse_args(["-Q", testquery, "-F", "jjssoonn"]) self.assertEqual(cm.exception.code, 2) self.assertEqual( sys.stderr.getvalue().split("\n")[1], "rqw: error: argument -F/--format: invalid choice: 'jjssoonn' (choose from 'json', 'xml', 'turtle', 'n3', 'rdf', 'rdf+xml', 'csv', 'tsv', 'json-ld')", )
def testQueryAndFile(self): with self.assertRaises(SystemExit) as cm: parse_args(["-Q", testquery, "-f", "-"]) self.assertEqual(cm.exception.code, 2) self.assertEqual( sys.stderr.getvalue().split("\n")[1], "rqw: error: argument -f/--file: not allowed with argument -Q/--query", )
def testNoarg(self): with self.assertRaises(SystemExit) as cm: parse_args([]) self.assertEqual(cm.exception.code, 2) self.assertEqual( sys.stderr.getvalue().split("\n")[1], "rqw: error: one of the arguments -f/--file -Q/--query is required", )
def testVersion(self): with self.assertRaises(SystemExit) as cm: parse_args(["-V"]) self.assertEqual(cm.exception.code, 0) self.assertEqual(sys.stdout.getvalue()[:3], "rqw")
def testHelp(self): with self.assertRaises(SystemExit) as cm: parse_args(["-h"]) self.assertEqual(cm.exception.code, 0) self.assertEqual(sys.stdout.getvalue()[:5], "usage")