From 10744dd816b7cc2bfa6a7ea8402ae21aac12838b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 16 Jan 2014 23:54:17 +0200 Subject: Add empty (false) value testing for strings, tuples, lists, dicts. --- tests/basics/tests/true-value.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/basics/tests/true-value.py (limited to 'tests') diff --git a/tests/basics/tests/true-value.py b/tests/basics/tests/true-value.py new file mode 100644 index 000000000..6ba410ddc --- /dev/null +++ b/tests/basics/tests/true-value.py @@ -0,0 +1,27 @@ +# Test true-ish value handling + +if not False: + print("False") + +if not 0: + print("0") + +if not "": + print("Empty string") +if "foo": + print("Non-empty string") + +if not (): + print("Empty tuple") +if ("",): + print("Non-empty tuple") + +if not []: + print("Empty list") +if [0]: + print("Non-empty list") + +if not {}: + print("Empty dict") +if {0:0}: + print("Non-empty dict") -- cgit v1.2.3