[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] tests: Add unit tests to Debug.py



commit 7a3db9879d0f9a6116456910207c4e2a19bf5169
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Mon Apr 8 10:08:36 2019 +1000

    tests: Add unit tests to Debug.py
    
    Part of 30063.
---
 lib/chutney/Debug.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/chutney/Debug.py b/lib/chutney/Debug.py
index 108735f..85c9eee 100755
--- a/lib/chutney/Debug.py
+++ b/lib/chutney/Debug.py
@@ -11,6 +11,7 @@ from __future__ import print_function
 
 import cgitb
 import os
+import sys
 
 # Get verbose tracebacks, so we can diagnose better.
 cgitb.enable(format="plain")
@@ -24,3 +25,18 @@ def debug(s):
     "Print a debug message on stdout if debug_flag is True."
     if debug_flag:
         print("DEBUG: %s" % s)
+
+
+def main():
+    global debug_flag
+    debug("This message should appear if $CHUTNEY_DEBUG is true.")
+    debug_flag = True
+    debug("This message should always appear.")
+    debug_flag = False
+    debug("This message should never appear.")
+    # We don't test tracebacks, because it's hard to know what to expect
+    # (and they make python exit with a non-zero exit status)
+    return 0
+
+if __name__ == '__main__':
+    sys.exit(main())



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits