Exemple #1
0
def test_create_config_file(tmp_path, caplog):
    with set_temp_config(tmp_path):
        create_config_file('astropy')

    # check that the config file has been created
    assert ('The configuration file has been successfully written'
            in caplog.records[0].message)
    assert os.path.exists(tmp_path / 'astropy' / 'astropy.cfg')

    with open(tmp_path / 'astropy' / 'astropy.cfg') as fp:
        conf = fp.read()
    check_config(conf)

    caplog.clear()

    # now modify the config file
    conf = conf.replace('# unicode_output = False', 'unicode_output = True')
    with open(tmp_path / 'astropy' / 'astropy.cfg', mode='w') as fp:
        fp.write(conf)

    with set_temp_config(tmp_path):
        create_config_file('astropy')

    # check that the config file has not been overwritten since it was modified
    assert ('The configuration file already exists and seems to have been '
            'customized' in caplog.records[0].message)

    caplog.clear()

    with set_temp_config(tmp_path):
        create_config_file('astropy', overwrite=True)

    # check that the config file has been overwritten
    assert ('The configuration file has been successfully written'
            in caplog.records[0].message)
Exemple #2
0
    def test_conf_pedantic_true(self, tmpdir):

        with set_temp_config(tmpdir.strpath):

            with open(tmpdir.join('astropy').join('astropy.cfg').strpath, 'w') as f:
                f.write('[io.votable]\npedantic = True')

            reload_config('astropy.io.votable')

            with pytest.raises(VOWarning):
                parse(get_pkg_data_filename('data/gemini.xml'))
Exemple #3
0
def test_generate_config2(tmp_path):
    """Test that generate_config works with the default filename."""

    with set_temp_config(tmp_path):
        from astropy.config.configuration import generate_config
        generate_config('astropy')

    assert os.path.exists(tmp_path / 'astropy' / 'astropy.cfg')

    with open(tmp_path / 'astropy' / 'astropy.cfg') as fp:
        conf = fp.read()

    check_config(conf)
Exemple #4
0
    def test_conf_pedantic_false(self, tmpdir):

        with set_temp_config(tmpdir.strpath):

            with open(tmpdir.join('astropy').join('astropy.cfg').strpath, 'w') as f:
                f.write('[io.votable]\npedantic = False')

            reload_config('astropy.io.votable')

            with catch_warnings(VOWarning, AstropyDeprecationWarning) as w:
                parse(get_pkg_data_filename('data/gemini.xml'))
            assert len(w) == 25
            # Make sure we don't yet emit a deprecation warning
            assert not any(isinstance(x.category, AstropyDeprecationWarning) for x in w)
Exemple #5
0
def test_generate_config2(tmp_path):
    """Test that generate_config works with the default filename."""

    with set_temp_config(tmp_path):
        from astropy.config.configuration import generate_config
        generate_config('astropy')

    assert os.path.exists(tmp_path / 'astropy' / 'astropy.cfg')

    with open(tmp_path / 'astropy' / 'astropy.cfg') as fp:
        conf = fp.read()

    # test that the output contains some lines that we expect
    assert '# unicode_output = False' in conf
    assert '[io.fits]' in conf
    assert '[visualization.wcsaxes]' in conf
    assert '## Whether to log exceptions before raising them.' in conf
    assert '# log_exceptions = False' in conf