From ba8247bd974e663c4d7087f1fdbe8a875ab52c3b Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Aug 2022 15:48:17 -0400 Subject: [PATCH] Add `makeNotation` argument to test utility --- music21/musicxml/test_m21ToXml.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/music21/musicxml/test_m21ToXml.py b/music21/musicxml/test_m21ToXml.py index d03121358e..08ddeee574 100644 --- a/music21/musicxml/test_m21ToXml.py +++ b/music21/musicxml/test_m21ToXml.py @@ -42,12 +42,16 @@ def getXml(self, obj): bytesOutUnicode = bytesOut.decode('utf-8') return bytesOutUnicode - def getET(self, obj): + def getET(self, obj, makeNotation=True): ''' Return a ElementTree. - Does NOT call makeNotation() like most calls to show() and write(). ''' + if makeNotation: + gex = GeneralObjectExporter() + obj = gex.fromGeneralObject(obj) + SX = ScoreExporter(obj) + SX.makeNotation = makeNotation mxScore = SX.parse() helpers.indent(mxScore) return mxScore @@ -457,10 +461,10 @@ def testOutOfBoundsExpressionDoesNotCreateForward(self): m.append(meter.TimeSignature('1/4')) m.append(note.Rest()) m.insert(2, tempo.MetronomeMark('slow', 40)) + p = stream.Part([m]) + s = stream.Score([p]) - gex = GeneralObjectExporter() - gex.makeNotation = False - tree = self.getET(gex.fromGeneralObject(m)) + tree = self.getET(s, makeNotation=False) self.assertFalse(tree.findall('.//forward')) self.assertEqual( int(tree.findall('.//direction/offset')[0].text), @@ -598,14 +602,13 @@ def testArpeggioMarkSpannersNonArpeggiate(self): def testExportChordSymbolsWithRealizedDurations(self): - gex = GeneralObjectExporter() - gex.makeNotation = False def realizeDurationsAndAssertTags(mm: stream.Measure, forwardTag=False, offsetTag=False): mm = copy.deepcopy(mm) harmony.realizeChordSymbolDurations(mm) - obj = gex.fromGeneralObject(mm) - tree = self.getET(obj) + p = stream.Part([mm]) + s = stream.Score([p]) + tree = self.getET(s, makeNotation=False) self.assertIs(bool(tree.findall('.//forward')), forwardTag) self.assertIs(bool(tree.findall('.//offset')), offsetTag)