python-benedict/tests/core/test_unique.py

59 lines
1.2 KiB
Python
Raw Normal View History

import unittest
from benedict.core import unique as _unique
class unique_test_case(unittest.TestCase):
2022-02-13 10:35:43 +00:00
"""
This class describes an unique test case.
"""
def test_unique(self):
d = {
2022-02-13 10:35:43 +00:00
"a": {
"x": 1,
"y": 1,
},
2022-02-13 10:35:43 +00:00
"b": {
"x": 2,
"y": 2,
},
2022-02-13 10:35:43 +00:00
"c": {
"x": 1,
"y": 1,
},
2022-02-13 10:35:43 +00:00
"d": {
"x": 1,
},
2022-02-13 10:35:43 +00:00
"e": {
"x": 1,
"y": 1,
"z": 1,
},
2022-02-13 10:35:43 +00:00
"f": {
"x": 2,
"y": 2,
},
}
_unique(d)
rv = [
{
2022-02-13 10:35:43 +00:00
"x": 1,
"y": 1,
},
{
2022-02-13 10:35:43 +00:00
"x": 2,
"y": 2,
},
{
2022-02-13 10:35:43 +00:00
"x": 1,
},
{
2022-02-13 10:35:43 +00:00
"x": 1,
"y": 1,
"z": 1,
},
]
self.assertEqual(len(d.keys()), len(rv))
self.assertTrue(all([value in rv for value in d.values()]))