Buffer output, print when errors occur. Introduce debug/quiet flags
This commit is contained in:
		
							
								
								
									
										14
									
								
								tests.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								tests.py
									
									
									
									
									
								
							| @@ -29,16 +29,13 @@ except ImportError: | ||||
|  | ||||
|  | ||||
| class YAMLTest(unittest.TestCase): | ||||
|     def __init__(self, testName, yaml_filename, yaml_schema, debug=False): | ||||
|     def __init__(self, testName, yaml_filename, yaml_schema): | ||||
|         # calling the super class init varies for different python versions.  This works for 2.7 | ||||
|         super(YAMLTest, self).__init__(testName) | ||||
|         self.yaml_filename = yaml_filename | ||||
|         self.yaml_schema = yaml_schema | ||||
|         self.debug = debug | ||||
|  | ||||
|     def test_yaml(self): | ||||
|         if self.debug: | ||||
|             print("%s ... " % self.yaml_filename, file=sys.stderr, end='') | ||||
|         unittest = None | ||||
|         cfg = None | ||||
|         n=0 | ||||
| @@ -74,8 +71,7 @@ class YAMLTest(unittest.TestCase): | ||||
|                     this_msg_expected = True | ||||
|                     break | ||||
|             if not this_msg_expected: | ||||
|                 if self.debug: | ||||
|                     print("%s: Unexpected message: %s" % (self.yaml_filename, m), file=sys.stderr) | ||||
|                 print("%s: Unexpected message: %s" % (self.yaml_filename, m), file=sys.stderr) | ||||
|                 fail = True | ||||
|  | ||||
|         count = 0 | ||||
| @@ -106,11 +102,11 @@ if __name__ == "__main__": | ||||
|     yaml_suite = unittest.TestSuite() | ||||
|     for pattern in args.test: | ||||
|         for fn in glob.glob(pattern): | ||||
|             yaml_suite.addTest(YAMLTest('test_yaml', yaml_filename=fn, yaml_schema=args.schema, debug=args.debug)) | ||||
|     yaml_ok = unittest.TextTestRunner(verbosity=verbosity).run(yaml_suite) | ||||
|             yaml_suite.addTest(YAMLTest('test_yaml', yaml_filename=fn, yaml_schema=args.schema)) | ||||
|     yaml_ok = unittest.TextTestRunner(verbosity=verbosity, buffer=True).run(yaml_suite) | ||||
|  | ||||
|     tests = unittest.TestLoader().discover(start_dir=".", pattern='test_*.py') | ||||
|     unit_ok = unittest.TextTestRunner(verbosity=verbosity).run(tests).wasSuccessful() | ||||
|     unit_ok = unittest.TextTestRunner(verbosity=verbosity, buffer=True).run(tests).wasSuccessful() | ||||
|  | ||||
|     if not yaml_ok or not unit_ok: | ||||
|         sys.exit(-1) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user