From 275371b03f4c6e26779093c51dbfc7b8b51e047b Mon Sep 17 00:00:00 2001 From: vict0rsch Date: Tue, 8 Dec 2020 08:47:45 +0100 Subject: [PATCH] add failure tests --- tests/test_parser.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_parser.py b/tests/test_parser.py index 0fc0033..55022d1 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -16,6 +16,11 @@ def run(args): return subprocess.run(COMMAND + args, capture_output=True).stdout.decode() +def fail(args): + assert isinstance(args, list) + return subprocess.run(COMMAND + args, capture_output=True).stderr.decode() + + def capture(minydict): f = io.StringIO() with redirect_stdout(f): @@ -50,4 +55,12 @@ def test_dotted(): assert run(["a.b.x=2"]) == capture(MinyDict({"a": {"b": {"x": 2}}})) -# TODO: add fail tests +def test_fail_equal(): + assert "MinydraWrongArgumentException" in fail(["a="]) + assert "MinydraWrongArgumentException" in fail(["="]) + assert "MinydraWrongArgumentException" in fail(["a = b"]) + assert "MinydraWrongArgumentException" in fail(["a= b"]) + + +def test_fail_dot(): + assert "MinydraWrongArgumentException" in fail([".a=3"])