def test_get_config_filename_not_implemented(self): test_json = '{"test":1}' with pytest.raises(NotImplementedError) as ctx: with patch("builtins.open", new_callable=mock_open, read_data=test_json): config_obj() assert ctx.errisinstance(NotImplementedError)
def test_json_error(self): test_json_error = '{"test:1}' with pytest.raises(json.JSONDecodeError) as ctx: with patch("builtins.open", new_callable=mock_open, read_data=test_json_error): config_obj() assert ctx.errisinstance(json.JSONDecodeError)
def test_wrong_data_type(self): test_json = 0xdeadbeef with pytest.raises(TypeError) as ctx: with patch("builtins.open", new_callable=mock_open, read_data=test_json): config_obj() assert ctx.errisinstance(TypeError)
def test_config_file_not_found(self): test_json = '{"test":1}' with pytest.raises(FileNotFoundError) as ctx: with patch("builtins.open", new_callable=mock_open, read_data=test_json): with patch("os.path.isfile", lambda x: False): config_obj() assert ctx.errisinstance(FileNotFoundError)
def test_base(self): test_json = '{"test":1}' with patch("builtins.open", new_callable=mock_open, read_data=test_json): some_config = config_obj() assert some_config.config == {'test': 1} assert some_config.get_config_dict() == {'test': 1}
def test_missing_config_filename(self): with pytest.raises(AttributeError) as ctx: with patch("builtins.open", lambda x: x): config_obj() assert ctx.errisinstance(AttributeError)