def test_get_envar_as_boolean_invalid(monkeypatch): monkeypatch.setenv("TEST_VAR", "foo") with pytest.raises(ValueError): assert util.get_envar_as_boolean("TEST_VAR")
def test_get_envar_as_boolean(monkeypatch, value, expected_result): monkeypatch.setenv("TEST_VAR", value) assert util.get_envar_as_boolean("TEST_VAR") is expected_result
def test_get_envar_as_boolean_default(monkeypatch): monkeypatch.delenv("TEST_VAR", raising=False) assert util.get_envar_as_boolean("TEST_VAR") is False assert util.get_envar_as_boolean("TEST_VAR", default=False) is False assert util.get_envar_as_boolean("TEST_VAR", default=True) is True
('Yes', True, True), ('YES', False, True), ('YES', True, True), ]) def test_get_envar_as_boolean(case, default, expected, jail_environ): """Test various options to a boolean environmental variable""" var = '__TEST_GET_ENVAR_AS_BOOLEAN' if case is None: try: del os.environ[var] except KeyError: pass else: os.environ[var] = case value = get_envar_as_boolean(var, default=default) assert value == expected @pytest.mark.skip("requires ImageModel") def test_getarray_noinit_valid(): """Test for valid value return""" arr = np.ones((5, 5)) model = ImageModel(data=arr) fetched = model.getarray_noinit('data') assert (fetched == arr).all() @pytest.mark.skip("requires ImageModel") def test_getarray_noinit_raises(): """Test for error when accessing non-existent array"""