From a8b2132f8f53287ed6b34a47eab39fea55b63995 Mon Sep 17 00:00:00 2001 From: Greg Chapman <75333244+gregchapman-dev@users.noreply.github.com> Date: Sun, 15 May 2022 13:20:47 -0700 Subject: [PATCH] Fix tests that return None. Fix "A guide to this new...". --- music21/metadata/__init__.py | 38 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/music21/metadata/__init__.py b/music21/metadata/__init__.py index 275e80a1bc..b8ec7af3ca 100644 --- a/music21/metadata/__init__.py +++ b/music21/metadata/__init__.py @@ -40,7 +40,7 @@ .. image:: images/moduleMetadata-01.* :width: 600 - A guide to this initial new implementation: + A guide to the 2022 Dublin Core implementation: - The guts of class Metadata are completely rewritten to support the new extensions, but all of Metadata's old APIs are still in place and @@ -442,10 +442,14 @@ def getItem(self, Test getItem when the item isn't there. >>> md = metadata.Metadata() - >>> md.getItem('title') # uniqueName - >>> md.getItem('title', namespace='dcterms') # name, namespace - >>> md.getItem('T', namespace='dcterms') # abbrevCode, namespace - >>> md.getItem('dcterms:title') # 'namespace:name' + >>> md.getItem('title') is None # uniqueName + True + >>> md.getItem('title', namespace='dcterms') is None # name, namespace + True + >>> md.getItem('T', namespace='dcterms') is None # abbrevCode, namespace + True + >>> md.getItem('dcterms:title') is None # 'namespace:name' + True Test getItem when the item is there: @@ -790,8 +794,10 @@ def uniqueNameToNSKey(uniqueName: str) -> t.Optional[str]: >>> metadata.Metadata.uniqueNameToNSKey('librettist') 'marcrel:LBT' - >>> metadata.Metadata.uniqueNameToNSKey('not a standard property') - >>> metadata.Metadata.uniqueNameToNSKey(None) + >>> metadata.Metadata.uniqueNameToNSKey('not a standard property') is None + True + >>> metadata.Metadata.uniqueNameToNSKey(None) is None + True >>> metadata.Metadata.uniqueNameToNSKey('alternativeTitle') 'dcterms:alternative' ''' @@ -832,8 +838,10 @@ def nsKeyToUniqueName(nsKey: str) -> t.Optional[str]: >>> metadata.Metadata.nsKeyToUniqueName('marcrel:LBT') 'librettist' - >>> metadata.Metadata.nsKeyToUniqueName('not a standard nskey') - >>> metadata.Metadata.nsKeyToUniqueName(None) + >>> metadata.Metadata.nsKeyToUniqueName('not a standard nskey') is None + True + >>> metadata.Metadata.nsKeyToUniqueName(None) is None + True >>> metadata.Metadata.nsKeyToUniqueName('dcterms:alternative') 'alternativeTitle' ''' @@ -852,9 +860,12 @@ def nsKeyToContributorUniqueName(nsKey: str) -> t.Optional[str]: >>> metadata.Metadata.nsKeyToContributorUniqueName('marcrel:LBT') 'librettist' - >>> metadata.Metadata.nsKeyToContributorUniqueName('not a standard nskey') - >>> metadata.Metadata.nsKeyToContributorUniqueName(None) - >>> metadata.Metadata.nsKeyToContributorUniqueName('dcterms:alternative') + >>> metadata.Metadata.nsKeyToContributorUniqueName('not a standard nskey') is None + True + >>> metadata.Metadata.nsKeyToContributorUniqueName(None) is None + True + >>> metadata.Metadata.nsKeyToContributorUniqueName('dcterms:alternative') is None + True ''' if not nsKey: return None @@ -914,7 +925,8 @@ def copyright(self) -> t.Optional[Copyright]: >>> md = metadata.Metadata() - >>> md.copyright + >>> md.copyright is None + True >>> md.setItem('dcterms:rights', 'Copyright © 1984 All Rights Reserved') >>> md.addItem('dcterms:rights', 'Lyrics copyright © 1987 All Rights Reserved') >>> md.copyright = 'Copyright © 1984 from str'