def test_read_paramsrc():
    """
    Test that the parameter file is read correctly and the resulting
    pysteps.paramsrc dict can be accessed by attributes too.
    """

    with NamedTemporaryFile(mode="w", delete=False) as tmp_paramsrc:
        tmp_paramsrc.write(minimal_pystepsrc_file)
        tmp_paramsrc.flush()

    # Perform a dry run that does not update
    # the internal pysteps.rcparams values.
    rcparams = load_config_file(tmp_paramsrc.name, dryrun=True, verbose=False)
    os.unlink(tmp_paramsrc.name)
    # Test item and attribute getters
    assert rcparams["data_sources"]["bom"]["fn_ext"] == "nc"
    assert rcparams.data_sources.bom.fn_ext == "nc"

    bom_datasource_as_dict = rcparams["data_sources"]["bom"]
    bom_datasource_as_attr = rcparams.data_sources.bom
    assert bom_datasource_as_dict is bom_datasource_as_attr
    bom_datasource = bom_datasource_as_attr

    timestep_as_dict = bom_datasource["timestep"]
    timestep_as_attr = bom_datasource.timestep
    assert timestep_as_dict == 6
    assert timestep_as_attr == 6
    assert timestep_as_dict is timestep_as_attr

    importer_kwargs_dict = bom_datasource["importer_kwargs"]
    importer_kwargs_attr = bom_datasource.importer_kwargs
    assert importer_kwargs_attr is importer_kwargs_dict

    assert importer_kwargs_attr["gzipped"] is importer_kwargs_attr.gzipped
    assert importer_kwargs_attr["gzipped"] is True

    # Test item and attribute setters
    rcparams.test = 4
    assert rcparams.test == 4
    assert rcparams.test is rcparams["test"]

    rcparams["test2"] = 4
    assert rcparams.test2 == 4
    assert rcparams.test2 is rcparams["test2"]

    rcparams.test = dict(a=1, b="test")
    assert rcparams.test == dict(a=1, b="test")
    assert rcparams.test["a"] == 1
    assert rcparams.test["b"] == "test"

    assert rcparams.test["a"] is rcparams["test"].a
    assert rcparams.test["b"] is rcparams["test"].b
Test that the parameter file is read correctly and the resulting
pysteps.paramsrc dict can be accessed by attributes too.
pysteps/tests/test_paramsrc.py