From b825a57a49ca199d07169176e55badd1d7e37e1b Mon Sep 17 00:00:00 2001 From: Tyler J Russell Date: Mon, 24 May 2021 19:36:56 +0100 Subject: [PATCH] test: add cli argument testing and fix docstrings --- tests/test_config_flag.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_config_flag.py b/tests/test_config_flag.py index 2f5ca25cf..4fecbb36b 100644 --- a/tests/test_config_flag.py +++ b/tests/test_config_flag.py @@ -1,16 +1,28 @@ -"""Check that the --config command-line flag works""" - +"""Test user option overrides using --config and load_options""" from proselint.tools import load_options def test_load_options_function(): + """Test load_options by specifying a user options path""" overrides = load_options("tests/test_config_flag_proselintrc") assert load_options()["checks"]["uncomparables.misc"] assert not overrides["checks"]["uncomparables.misc"] def test_load_fallbacks(): + """Test load_options with a fallback path""" fallbacks = load_options(None, ["tests/test_config_flag_proselintrc"]) assert not fallbacks["checks"]["uncomparables.misc"] fallbacks = load_options(None, ["./.proselintrc"]) assert fallbacks["checks"]["uncomparables.misc"] + + +def test_config_flag(): + """Test the --config CLI argument""" + output = subprocess.run(["python", "-m", "proselint", "--demo"], + stdout=subprocess.PIPE, encoding='utf-8') + assert "uncomparables.misc" in output.stdout + output = subprocess.run(["python", "-m", "proselint", "--demo", "--config", + "tests/test_config_flag_proselintrc"], + stdout=subprocess.PIPE, encoding='utf-8') + assert "uncomparables.misc" not in output.stdout