# Path: ckan_api_client/utils.py
# def freeze(obj):
#     """
#     Returns the "frozen" version of a mutable type.
# 
#     :raises TypeError:
#         if a frozen version for that object doesn't exist
#     """
#     if obj is None:
#         return None
#     if isinstance(obj, (basestring, int, float, bool)):
#         return obj
#     if isinstance(obj, dict):
#         return FrozenDict(obj)
#     if isinstance(obj, list):
#         return FrozenList(obj)
#     if isinstance(obj, tuple):
#         return FrozenTuple(obj)
#     raise TypeError("I don't know how to freeze this!")
# 
# class FrozenDict(MutableMapping):
#     """
#     Frozen dictionary.
#     Acts as a read-only dictionary, preventing changes
#     and returning frozen objects when asked for values.
#     """
# 
#     def __init__(self, *a, **kw):
#         self.__wrapped = dict(*a, **kw)
# 
#     def __getitem__(self, name):
#         return freeze(self.__wrapped[name])
# 
#     def __setitem__(self, name, value):
#         raise TypeError("FrozenDict doesn't support item assignment")
# 
#     def __delitem__(self, name):
#         raise TypeError("FrozenDict doesn't support item deletion")
# 
#     def __iter__(self):
#         return iter(self.__wrapped)
# 
#     def __len__(self):
#         return len(self.__wrapped)
# 
# class FrozenList(FrozenSequence):
#     """Immutable list-like."""
#     pass


import pytest
from ckan_api_client.utils import freeze, FrozenDict, FrozenList
    assert my_list == list(my_frozen_list)

    my_list.append('bacon')
    assert my_list == ['egg', 'spam', 'bacon']
    assert list(my_frozen_list) == ['egg', 'spam', 'bacon']

    with pytest.raises(TypeError):
        my_frozen_list[1] = 'SPAM!!'

    with pytest.raises(AttributeError):
        my_frozen_list.pop(0)

    with pytest.raises(AttributeError):
        my_frozen_list.extend(['spam'] * 10)


def test_frozen_nested():
    frozobj = freeze({
        'a list': [1, 2, 'a', 'b'],
        'a dict': {
            'key1': 'val1',
            'key2': 'val2',
        },
        'another list': [
            {'name': 'eggs', 'price': 1},
            {'name': 'spam', 'price': 2},
            {'name': 'bacon', 'price': 3},
        ]
    })


# Path: ckan_api_client/utils.py
# def freeze(obj):
#     """
#     Returns the "frozen" version of a mutable type.
# 
#     :raises TypeError:
#         if a frozen version for that object doesn't exist
#     """
#     if obj is None:
#         return None
#     if isinstance(obj, (basestring, int, float, bool)):
#         return obj
#     if isinstance(obj, dict):
#         return FrozenDict(obj)
#     if isinstance(obj, list):
#         return FrozenList(obj)
#     if isinstance(obj, tuple):
#         return FrozenTuple(obj)
#     raise TypeError("I don't know how to freeze this!")
# 
# class FrozenDict(MutableMapping):
#     """
#     Frozen dictionary.
#     Acts as a read-only dictionary, preventing changes
#     and returning frozen objects when asked for values.
#     """
# 
#     def __init__(self, *a, **kw):
#         self.__wrapped = dict(*a, **kw)
# 
#     def __getitem__(self, name):
#         return freeze(self.__wrapped[name])
# 
#     def __setitem__(self, name, value):
#         raise TypeError("FrozenDict doesn't support item assignment")
# 
#     def __delitem__(self, name):
#         raise TypeError("FrozenDict doesn't support item deletion")
# 
#     def __iter__(self):
#         return iter(self.__wrapped)
# 
#     def __len__(self):
#         return len(self.__wrapped)
# 
# class FrozenList(FrozenSequence):
#     """Immutable list-like."""
#     pass


# Path: ckan_api_client/tests/unit/test_frozen_objects.py
import pytest
from ckan_api_client.utils import freeze, FrozenDict, FrozenList

    assert my_list == list(my_frozen_list)

    my_list.append('bacon')
    assert my_list == ['egg', 'spam', 'bacon']
    assert list(my_frozen_list) == ['egg', 'spam', 'bacon']

    with pytest.raises(TypeError):
        my_frozen_list[1] = 'SPAM!!'

    with pytest.raises(AttributeError):
        my_frozen_list.pop(0)

    with pytest.raises(AttributeError):
        my_frozen_list.extend(['spam'] * 10)


def test_frozen_nested():
    frozobj = freeze({
        'a list': [1, 2, 'a', 'b'],
        'a dict': {
            'key1': 'val1',
            'key2': 'val2',
        },
        'another list': [
            {'name': 'eggs', 'price': 1},
            {'name': 'spam', 'price': 2},
            {'name': 'bacon', 'price': 3},
        ]
    })


    assert isinstance(frozobj, FrozenDict)