def test_config_noastropy_fallback(monkeypatch):
 from ...tests.helper import pytest
 monkeypatch.setenv(str(u'XDG_CONFIG_HOME'), u'foo')
 monkeypatch.delenv(str(u'XDG_CONFIG_HOME'))
 monkeypatch.setattr(paths.set_temp_config, u'_temp_path', None)
 def osraiser(dirnm, linkto):
  raise OSError
 monkeypatch.setattr(paths, u'_find_or_create_astropy_dir', osraiser)
 monkeypatch.setattr(configuration, u'_cfgobjs', {})
 with pytest.raises(OSError):
  paths.get_config_dir()
 with catch_warnings(configuration.ConfigurationMissingWarning) as w:
  test_configitem()
 assert (len(w) == 1)
 w = w[0]
 assert (u'Configuration defaults will be used' in str(w.message))

def test_config_noastropy_fallback ( monkeypatch ) : from ... tests . helper import pytest monkeypatch . setenv ( str ( u'XDG_CONFIG_HOME' ) , u'foo' ) monkeypatch . delenv ( str ( u'XDG_CONFIG_HOME' ) ) monkeypatch . setattr ( paths . set_temp_config , u'_temp_path' , None ) def osraiser ( dirnm , linkto ) : raise OSError monkeypatch . setattr ( paths , u'_find_or_create_astropy_dir' , osraiser ) monkeypatch . setattr ( configuration , u'_cfgobjs' , { } ) with pytest . raises ( OSError ) : paths . get_config_dir ( ) with catch_warnings ( configuration . ConfigurationMissingWarning ) as w : test_configitem ( ) assert ( len ( w ) == 1 ) w = w [ 0 ] assert ( u'Configuration defaults will be used' in str ( w . message ) )
tests to make sure configuration items fall back to their defaults when theres a problem accessing the astropy directory .