# Path: sacred/config/config_files.py
# HANDLER_BY_EXT = {
#     ".json": Handler(
#         lambda fp: restore(json.load(fp)),
#         lambda obj, fp: json.dump(flatten(obj), fp, sort_keys=True, indent=2),
#         "",
#     ),
#     ".pickle": Handler(pickle.load, pickle.dump, "b"),
# }
# 
# def load_config_file(filename):
#     handler = get_handler(filename)
#     with open(filename, "r" + handler.mode) as f:
#         return handler.load(f)


import os
import re
import tempfile
import pytest
from sacred.config.config_files import HANDLER_BY_EXT, load_config_file
#!/usr/bin/env python
# coding=utf-8




data = {"foo": 42, "baz": [1, 0.2, "bar", True, {"some_number": -12, "simon": "hugo"}]}


@pytest.mark.parametrize("handler", HANDLER_BY_EXT.values())
def test_save_and_load(handler):
    with tempfile.TemporaryFile("w+" + handler.mode) as f:
        handler.dump(data, f)
        f.seek(0)  # simulates closing and reopening
        d = handler.load(f)
        assert d == data



# Path: sacred/config/config_files.py
# HANDLER_BY_EXT = {
#     ".json": Handler(
#         lambda fp: restore(json.load(fp)),
#         lambda obj, fp: json.dump(flatten(obj), fp, sort_keys=True, indent=2),
#         "",
#     ),
#     ".pickle": Handler(pickle.load, pickle.dump, "b"),
# }
# 
# def load_config_file(filename):
#     handler = get_handler(filename)
#     with open(filename, "r" + handler.mode) as f:
#         return handler.load(f)


# Path: tests/test_config/test_config_files.py
import os
import re
import tempfile
import pytest
from sacred.config.config_files import HANDLER_BY_EXT, load_config_file

#!/usr/bin/env python
# coding=utf-8




data = {"foo": 42, "baz": [1, 0.2, "bar", True, {"some_number": -12, "simon": "hugo"}]}


@pytest.mark.parametrize("handler", HANDLER_BY_EXT.values())
def test_save_and_load(handler):
    with tempfile.TemporaryFile("w+" + handler.mode) as f:
        handler.dump(data, f)
        f.seek(0)  # simulates closing and reopening
        d = handler.load(f)
        assert d == data



@pytest.mark.parametrize("ext, handler", HANDLER_BY_EXT.items())