Exemple #1
0
    def test_get_fail(self):
        """Test bad inputs to :meth:`astropy.cosmology.default_cosmology.get`."""
        # a not-valid option, but still a str
        with pytest.raises(ValueError, match="Unknown cosmology"):
            cosmo = default_cosmology.get("fail!")

        # a not-valid type
        with pytest.raises(TypeError, match="'key' must be must be"):
            cosmo = default_cosmology.get(object())
Exemple #2
0
 def test_get_current(self):
     """Test :meth:`astropy.cosmology.default_cosmology.get` current value."""
     cosmo = default_cosmology.get()
     assert cosmo is default_cosmology.validate(default_cosmology._value)
Exemple #3
0
 def test_get_valid(self, name):
     """Test :meth:`astropy.cosmology.default_cosmology.get` from str."""
     cosmo = default_cosmology.get(name)
     assert cosmo is getattr(realizations, name)
Exemple #4
0
 def test_get_none(self):
     """Test :meth:`astropy.cosmology.default_cosmology.get` to `None`."""
     cosmo = default_cosmology.get("no_default")
     assert cosmo is None