assert err == "", err lines = out.splitlines(True) assert lines for line in lines: assert line m = re.match("([^ ]*) *([^ ]+)", line) assert m is not None, line key = m.groups()[0] key = key.strip() value = m.groups()[1] # TODO: replace the following line by stripping colorcodes or add an option --no-color value = value.strip()[5:-4] assert key in settings_dict assert value == str(settings_dict[key]) def test_cli_df(capsys): app = CliMetLabApp() app.onecmd("df") out, err = capsys.readouterr() assert out.startswith("DiskUsage("), out assert err == "", err if __name__ == "__main__": from climetlab.testing import main main(__file__)
def test_bbox(): area = [30.0, 2.0, 3.0, 4.0] bbox = BoundingBox(north=30, west=2, south=3, east=4) assert bbox_list(None, area) == bbox assert bbox_list(area=area, ignore=None) == bbox assert bbox_tuple(area) == tuple(area) assert bbox_tuple(area=area) == tuple(area) assert bbox_bbox(area) == area assert bbox_dict(area) == dict(north=30, west=2, south=3, east=4) assert bbox_defaults(area) == bbox source = load_source("file", climetlab_file("docs/examples/test.grib")) assert bbox_tuple(source[0]) == (73.0, -27.0, 33.0, 45.0) source = load_source("file", climetlab_file("docs/examples/test.nc")) assert bbox_tuple(source[0]) == (73.0, -27.0, 33.0, 45.0) if __name__ == "__main__": from climetlab.testing import main main(globals())