Skip to content

Commit

Permalink
Merge pull request #1376 from cuthbertLab/getET
Browse files Browse the repository at this point in the history
Add `makeNotation` argument to test utility
  • Loading branch information
mscuthbert authored Aug 15, 2022
2 parents 1a0ec50 + ba8247b commit d68cdd6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions music21/musicxml/test_m21ToXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <score-partwise> 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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit d68cdd6

Please sign in to comment.