#
# Copyright (C) 2011 - 2016 Satoru SATOH <ssato at redhat.com>
#
# pylint: disable=missing-docstring
from __future__ import absolute_import


def dicts_equal(lhs, rhs):
    """
    >>> dicts_equal({}, {})
    True
    >>> dicts_equal({}, {'a': 1})
    False
    >>> d0 = {'a': 1}; dicts_equal(d0, d0)
    True
    >>> d1 = {'a': [1, 2, 3]}; dicts_equal(d1, d1)
    True
    >>> dicts_equal(d0, d1)
    False
    """
    if len(lhs.keys()) != len(rhs.keys()):
        return False

    for key, val in rhs.items():
        val_ref = lhs.get(key, None)
        if val != val_ref:
            return False

    return True

# vim:sw=4:ts=4:et:

#
# Copyright (C) 2011 - 2016 Satoru SATOH <ssato at redhat.com>
#
# pylint: disable=missing-docstring
from __future__ import absolute_import
import unittest


def dicts_equal(lhs, rhs):
    """
    Check dicts' equality.
    """
    if len(lhs.keys()) != len(rhs.keys()):
        return False

    for key, val in rhs.items():
        val_ref = lhs.get(key, None)
        if val != val_ref:
            return False

    return True


class Test00(unittest.TestCase):

    def test_10_dicts_equal(self):
        self.assertTrue(dicts_equal({}, {}))
        self.assertFalse(dicts_equal({}, {'a': 1}))

        d0 = {'a': 1}
        d1 = {'a': [1, 2, 3]}
        self.assertTrue(dicts_equal(d0, d0))
        self.assertFalse(dicts_equal(d0, d1))

# vim:sw=4:ts=4:et:

add test cases of m9dicts.tests.common.* explicitly (not doctest)