def main(description): """Main function called when run_tests is run from the command-line Args: description (str): description printed to usage message """ args = _commandline_args(description) verbosity = _get_verbosity_level(args) if args.pattern is not None: pattern = args.pattern elif args.unit: pattern = 'test_unit*.py' elif args.sys: pattern = 'test_sys*.py' else: pattern = 'test*.py' # This setup_for_tests call is the main motivation for having this wrapper script to # run the tests rather than just using 'python -m unittest discover' unit_testing.setup_for_tests(enable_critical_logs=args.debug) mydir = os.path.dirname(os.path.abspath(__file__)) testsuite = unittest.defaultTestLoader.discover(start_dir=mydir, pattern=pattern) # NOTE(wjs, 2018-08-29) We may want to change the meaning of '--debug' # vs. '--verbose': I could imagine having --verbose set buffer=False, and --debug # additionally sets the logging level to much higher - e.g., debug level. testrunner = unittest.TextTestRunner(buffer=(not args.debug), verbosity=verbosity) testrunner.run(testsuite)
longxy=longxy, latixy=latixy) def _get_longxy_latixy(self, _min_lon, _max_lon, _min_lat, _max_lat): """ Return longxy, latixy, cols, rows """ cols = _max_lon - _min_lon + 1 rows = _max_lat - _min_lat + 1 long = np.arange(_min_lon, _max_lon + 1) long = [lon_range_0_to_360(longitude) for longitude in long] longxy = long * np.ones((rows,cols)) compare = np.repeat([long], rows, axis=0) # alternative way to form # assert this to confirm intuitive understanding of these matrices np.testing.assert_array_equal(longxy, compare) lati = np.arange(_min_lat, _max_lat + 1) self.assertEqual(min(lati), _min_lat) self.assertEqual(max(lati), _max_lat) latixy_transp = lati * np.ones((cols,rows)) compare = np.repeat([lati], cols, axis=0) # alternative way to form # assert this to confirm intuitive understanding of these matrices np.testing.assert_array_equal(latixy_transp, compare) latixy = np.transpose(latixy_transp) return longxy, latixy, cols, rows if __name__ == '__main__': unit_testing.setup_for_tests() unittest.main()