# Path: uqbar/objects.py
# def get_hash(expr):
#     args, var_args, kwargs = get_vars(expr)
#     hash_values = [type(expr)]
#     for key, value in args.items():
#         if isinstance(value, list):
#             value = tuple(value)
#         elif isinstance(value, set):
#             value = frozenset(value)
#         elif isinstance(value, dict):
#             value = tuple(sorted(value.items()))
#         args[key] = value
#     hash_values.append(tuple(args.items()))
#     hash_values.append(tuple(var_args))
#     for key, value in kwargs.items():
#         if isinstance(value, list):
#             value = tuple(value)
#         elif isinstance(value, set):
#             value = frozenset(value)
#         elif isinstance(value, dict):
#             value = tuple(sorted(value.items()))
#         kwargs[key] = value
#     hash_values.append(tuple(sorted(kwargs.items())))
#     return hash(tuple(hash_values))


from uqbar.objects import get_hash


class MyObject:
    def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
        self.arg1 = arg1
        self.arg2 = arg2
        self.var_args = var_args
        self.foo = foo
        self.bar = bar
        self.kwargs = kwargs


def test_objects_get_hash_01():
    object_a = MyObject("a", "b", "c", "d", foo="x", quux=["y", "z"])
    object_b = MyObject("a", "b", "c", "d", foo="x", quux=["y", "z"])
    object_c = MyObject("x", "y", bar=set([1, 2, 3]))
    assert get_hash(object_a) == get_hash(object_b)

# Path: uqbar/objects.py
# def get_hash(expr):
#     args, var_args, kwargs = get_vars(expr)
#     hash_values = [type(expr)]
#     for key, value in args.items():
#         if isinstance(value, list):
#             value = tuple(value)
#         elif isinstance(value, set):
#             value = frozenset(value)
#         elif isinstance(value, dict):
#             value = tuple(sorted(value.items()))
#         args[key] = value
#     hash_values.append(tuple(args.items()))
#     hash_values.append(tuple(var_args))
#     for key, value in kwargs.items():
#         if isinstance(value, list):
#             value = tuple(value)
#         elif isinstance(value, set):
#             value = frozenset(value)
#         elif isinstance(value, dict):
#             value = tuple(sorted(value.items()))
#         kwargs[key] = value
#     hash_values.append(tuple(sorted(kwargs.items())))
#     return hash(tuple(hash_values))


# Path: tests/test_objects_get_hash.py
from uqbar.objects import get_hash



class MyObject:
    def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
        self.arg1 = arg1
        self.arg2 = arg2
        self.var_args = var_args
        self.foo = foo
        self.bar = bar
        self.kwargs = kwargs


def test_objects_get_hash_01():
    object_a = MyObject("a", "b", "c", "d", foo="x", quux=["y", "z"])
    object_b = MyObject("a", "b", "c", "d", foo="x", quux=["y", "z"])
    object_c = MyObject("x", "y", bar=set([1, 2, 3]))
    assert get_hash(object_a) == get_hash(object_b)

    assert get_hash(object_a) != get_hash(object_c)