mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-25 10:48:18 +00:00
Introduce _node_skip_empty_iter() to reduce code redundancy
This commit is contained in:
committed by
Philipp Wolfer
parent
1c566ca08c
commit
ac57f95d92
@@ -33,6 +33,7 @@ from test.picardtestcase import (
|
||||
from picard import config
|
||||
from picard.album import Album
|
||||
from picard.mbjson import (
|
||||
_node_skip_empty_iter,
|
||||
_translate_artist_node,
|
||||
artist_to_metadata,
|
||||
countries_from_node,
|
||||
@@ -64,6 +65,25 @@ settings = {
|
||||
}
|
||||
|
||||
|
||||
class MBJSONItersTest(PicardTestCase):
|
||||
def test_node_skip_empty_iter(self):
|
||||
d = {
|
||||
'bool_false': False,
|
||||
'bool_true': True,
|
||||
'int_0': 0,
|
||||
'int_1': 1,
|
||||
'float_0': 0.0,
|
||||
'float_1': 1.1,
|
||||
'list_empty': [],
|
||||
'list_non_empty': ['a'],
|
||||
'dict_empty': {},
|
||||
'dict_non_empty': {'a': 'b'},
|
||||
}
|
||||
expected = set(d) - {'list_empty', 'dict_empty'}
|
||||
result = set({k: v for k, v in _node_skip_empty_iter(d)})
|
||||
self.assertSetEqual(expected, result)
|
||||
|
||||
|
||||
class MBJSONTest(PicardTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
Reference in New Issue
Block a user