summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-10-22 17:43:16 -0500
committerptmcg <ptmcg@austin.rr.com>2021-10-22 17:43:16 -0500
commit686852fa90700d8434082cf151af36ea000c2418 (patch)
treeb77cedfbdd56782c1b854cd852150cdf8f80d383 /tests
parent3edde380a24a4bcef346519298f52a3d324c2d17 (diff)
downloadpyparsing-git-686852fa90700d8434082cf151af36ea000c2418.tar.gz
Added support for python -W warning option to call enable_all_warnings() at startup. Also detects setting of PYPARSINGENABLEALLWARNINGS environment variable to any non-blank value.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_unit.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py
index 110fed8..46523bc 100644
--- a/tests/test_unit.py
+++ b/tests/test_unit.py
@@ -102,6 +102,37 @@ class Test01_PyparsingTestInit(TestCase):
print("Python version", sys.version)
+class Test01a_PyparsingEnvironmentTests(TestCase):
+ def runTest(self):
+ # test warnings enable detection
+ tests = [
+ (([], "",), False),
+ ((["d", ], "",), True),
+ ((["d", "i:::pyparsing", ], "",), False),
+ ((["d:::pyparsing", ], "",), True),
+ ((["d:::pyparsing", "i", ], "",), False),
+ ((["d:::blah", ], "",), False),
+ ((["i", ], "",), False),
+ (([], "1",), True),
+ ((["d", ], "1",), True),
+ ((["d", "i:::pyparsing", ], "1",), False),
+ ((["d:::pyparsing", ], "1",), True),
+ ((["d:::pyparsing", "i", ], "1",), False),
+ ((["d:::blah", ], "1",), True),
+ ((["i", ], "1",), False),
+ ]
+
+ all_success = True
+ for args, expected in tests:
+ message = "{} should be {}".format(args, expected)
+ print(message, end=" -> ")
+ actual = pp.core._should_enable_warnings(*args)
+ print("PASS" if actual == expected else "FAIL")
+ if actual != expected:
+ all_success = False
+ self.assertTrue(all_success, "failed warnings enable test")
+
+
class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
suite_context = None
save_suite_context = None