Changeset View
Changeset View
Standalone View
Standalone View
swh/core/tests/test_logger.py
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | assert sorted(logger.flatten({'a': 1, | ||||
('a', 1), | ('a', 1), | ||||
('b_0', 2), | ('b_0', 2), | ||||
('b_1', 3), | ('b_1', 3), | ||||
('c_d', 4), | ('c_d', 4), | ||||
('c_e', 'f'), | ('c_e', 'f'), | ||||
] | ] | ||||
def test_flatten_dict_binary_keys(): | |||||
d = {b"a": "a"} | |||||
str_d = str(d) | |||||
assert list(logger.flatten(d)) == [("", str_d)] | |||||
assert list(logger.flatten({"a": d})) == [("a", str_d)] | |||||
assert list(logger.flatten({"a": [d, d]})) == [ | |||||
("a_0", str_d), ("a_1", str_d) | |||||
] | |||||
def test_stringify(): | def test_stringify(): | ||||
assert logger.stringify(None) == 'None' | assert logger.stringify(None) == 'None' | ||||
assert logger.stringify(123) == '123' | assert logger.stringify(123) == '123' | ||||
assert logger.stringify('abc') == 'abc' | assert logger.stringify('abc') == 'abc' | ||||
date = datetime(2019, 9, 1, 16, 32) | date = datetime(2019, 9, 1, 16, 32) | ||||
assert logger.stringify(date) == '2019-09-01T16:32:00' | assert logger.stringify(date) == '2019-09-01T16:32:00' | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |