Repository: cuthbertLab/music21
Pull request #844 (2021-02-09 23:47:56)

Stream coverage
Also unify the derivation methods

coveralls: 
[![Coverage Status](https://coveralls.io/builds/37003691/badge)](https://coveralls.io/builds/37003691)

Coverage increased (+0.06%) to 91.623% when pulling **e572774a398033f729ed847c482c49785b139fc5 on more_cover** into **97c29868fd2ec789f8cc216842f1c91b5c04aae5 on master**.


Patch:
diff --git a/music21/base.py b/music21/base.py
index d367130b7..3ac697066 100644
--- a/music21/base.py
+++ b/music21/base.py
@@ -2741,6 +2741,7 @@ class Music21Object(prebase.ProtoM21Object):
     def splitAtQuarterLength(
         self,
         quarterLength,
+        *,
         retainOrigin=True,
         addTies=True,
         displayTiedAccidentals=False
@@ -2853,6 +2854,8 @@ class Music21Object(prebase.ProtoM21Object):
         Traceback (most recent call last):
         music21.duration.DurationException: cannot split a duration (0.5)
             at this quarterLength (7/10)
+
+        Changed in v7. -- all but quarterLength are keyword only
         '''
         # needed for temporal manipulations; not music21 objects
         from music21 import tie
diff --git a/music21/stream/__init__.py b/music21/stream/__init__.py
index b68e1f3d1..db77ccee7 100644
--- a/music21/stream/__init__.py
+++ b/music21/stream/__init__.py
@@ -1013,6 +1013,14 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         >>> p2.staffLines
         5
 
+        OMIT_FROM_DOCS
+
+        Check that staffLayout is altered by staffLayout setter:
+
+        >>> m.staffLines = 2
+        >>> staffLayout.staffLines
+        2
+
         '''
         staffLayouts = self.recurse().getElementsByClass('StaffLayout')
         sl: 'music21.layout.StaffLayout'
@@ -1031,7 +1039,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             sl: 'music21.layout.StaffLayout' = layout.StaffLayout(staffLines=newStaffLines)
             self.insert(0.0, sl)
         else:
-            firstLayout = staffLayouts[0]
+            firstLayout = staffLayouts.first()
             firstLayout.staffLines = newStaffLines
 
 
@@ -1415,7 +1423,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
         # TODO: Add a renumber measures option
         # TODO: Shift offsets if recurse is True
-        if shiftOffsets is True and recurse is True:
+        if shiftOffsets is True and recurse is True:  # pragma: no cover
             raise StreamException(
                 'Cannot do both shiftOffsets and recurse search at the same time...yet')
 
@@ -1612,11 +1620,11 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
                             }
         if ignoreAttributes is None:
             ignoreAttributes = defaultIgnoreSet
-        else:
+        else:  # pragma: no cover
             ignoreAttributes = ignoreAttributes | defaultIgnoreSet
         new = super()._deepcopySubclassable(memo, ignoreAttributes, removeFromIgnore)
 
-        if removeFromIgnore is not None:
+        if removeFromIgnore is not None:  # pragma: no cover
             ignoreAttributes = ignoreAttributes - removeFromIgnore
 
         if '_offsetDict' in ignoreAttributes:
@@ -1837,6 +1845,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             for idElement in self._offsetDict:  # slower search
                 o, returnedElement = self._offsetDict[idElement]
                 if element is returnedElement:
+                    # MSC 2021 -- it is possible this no longer ever happens,
+                    #    currently uncovered in Coverage.
                     break
             else:
                 raise base.SitesException(
@@ -1956,10 +1966,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         try:  # using float conversion instead of isNum for performance
             offset = float(offset)
         except (ValueError, TypeError):
-            if offset is None:
-                offset = 0.0
-            else:
-                raise StreamException(f'Offset {offset!r} must be a number.')
+            raise StreamException(f'Offset {offset!r} must be a number.')
 
         if not isinstance(item, base.Music21Object):
             raise StreamException('to put a non Music21Object in a stream, '
@@ -2711,6 +2718,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
     def splitAtQuarterLength(self,
                              quarterLength,
+                             *,
                              retainOrigin=True,
                              addTies=True,
                              displayTiedAccidentals=False,
@@ -2720,23 +2728,29 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         similar functionality for Streams.
 
         Most arguments are passed to Music21Object.splitAtQuarterLength.
+
+        Changed in v7. -- all but quarterLength are keyword only
         '''
         # pylint: disable=attribute-defined-outside-init
         quarterLength = opFrac(quarterLength)
         if retainOrigin:
             sLeft = self
         else:
-            sLeft = copy.deepcopy(self)
+            sLeft = self.coreCopyAsDerivation('splitAtQuarterLength')
         # create empty container for right-hand side
         sRight = self.__class__()
 
         # if this is a Measure or Part, transfer clefs, ts, and key
         if sLeft.isMeasure:
             timeSignatures = sLeft.getTimeSignatures(
-                searchContext=searchContext)
+                searchContext=searchContext,
+                returnDefault=False,
+            )
             if timeSignatures:
                 sRight.keySignature = copy.deepcopy(timeSignatures[0])
-            keySignatures = sLeft.getKeySignatures(searchContext=searchContext)
+            keySignatures = sLeft.getKeySignatures(
+                searchContext=searchContext,
+            )
             if keySignatures:
                 sRight.keySignature = copy.deepcopy(keySignatures[0])
             endClef = sLeft.getContextByClass('Clef')
@@ -2791,13 +2805,13 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         return sLeft, sRight
 
     # --------------------------------------------------------------------------
-    def _recurseRepr(self,
-                     thisStream,
-                     prefixSpaces=0,
-                     addBreaks=True,
-                     addIndent=True,
-                     addEndTimes=False,
-                     useMixedNumerals=False):
+    def recurseRepr(self,
+                    *,
+                    prefixSpaces=0,
+                    addBreaks=True,
+                    addIndent=True,
+                    addEndTimes=False,
+                    useMixedNumerals=False):
         '''
         Used by .show('text') to display a stream's contents with offsets.
 
@@ -2808,14 +2822,16 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         >>> s3.append(n1)
         >>> s2.append(s3)
         >>> s1.append(s2)
-        >>> post = s1._recurseRepr(s1, addBreaks=False, addIndent=False)
+        >>> post = s1.recurseRepr(addBreaks=False, addIndent=False)
         >>> post
         '{0.0} <music21.stream.Stream ...> / {0.0} <...> / {0.0} <music21.note.Note C>'
+
+        Made public in v7.  Always calls on self.
         '''
         def singleElement(in_element,
                           in_indent,
                           ) -> str:
-            offGet = in_element.getOffsetBySite(thisStream)
+            offGet = in_element.getOffsetBySite(self)
             if useMixedNumerals:
                 off = common.mixedNumeral(offGet)
             else:
@@ -2832,7 +2848,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
         msg = []
         insertSpaces = 4
-        for element in thisStream:
+        for element in self:
             if addIndent:
                 indent = ' ' * prefixSpaces
             else:
@@ -2841,12 +2857,13 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             # if isinstance(element, Stream):
             if element.isStream:
                 msg.append(singleElement(element, indent))
-                msg.append(self._recurseRepr(element,
-                                             prefixSpaces + insertSpaces,
-                                             addBreaks=addBreaks,
-                                             addIndent=addIndent,
-                                             addEndTimes=addEndTimes,
-                                             useMixedNumerals=useMixedNumerals))
+                msg.append(
+                    element.recurseRepr(prefixSpaces=prefixSpaces + insertSpaces,
+                                        addBreaks=addBreaks,
+                                        addIndent=addIndent,
+                                        addEndTimes=addEndTimes,
+                                        useMixedNumerals=useMixedNumerals)
+                )
             else:
                 msg.append(singleElement(element, indent))
         if addBreaks:
@@ -2855,46 +2872,26 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             msg = ' / '.join(msg)
         return msg
 
-    def _reprText(self, **keywords):
+    def _reprText(self, *, addEndTimes=False, useMixedNumerals=False):
         '''
         Return a text representation. This methods can be overridden by
         subclasses to provide alternative text representations.
 
         This is used by .show('text')
         '''
-        if 'addEndTimes' in keywords:
-            addEndTimes = keywords['addEndTimes']
-        else:
-            addEndTimes = False
-        if 'useMixedNumerals' in keywords:
-            useMixedNumerals = keywords['useMixedNumerals']
-        else:
-            useMixedNumerals = False
+        return self.recurseRepr(addEndTimes=addEndTimes,
+                                useMixedNumerals=useMixedNumerals)
 
-        return self._recurseRepr(self,
-                                 addEndTimes=addEndTimes,
-                                 useMixedNumerals=useMixedNumerals)
-
-    def _reprTextLine(self, **keywords):
+    def _reprTextLine(self, *, addEndTimes=False, useMixedNumerals=False):
         '''
         Return a text representation without line breaks.
         This methods can be overridden by subclasses to
         provide alternative text representations.
         '''
-        if 'addEndTimes' in keywords:
-            addEndTimes = keywords['addEndTimes']
-        else:
-            addEndTimes = False
-        if 'useMixedNumerals' in keywords:
-            useMixedNumerals = keywords['useMixedNumerals']
-        else:
-            useMixedNumerals = False
-
-        return self._recurseRepr(self,
-                                 addEndTimes=addEndTimes,
-                                 useMixedNumerals=useMixedNumerals,
-                                 addBreaks=False,
-                                 addIndent=False)
+        return self.recurseRepr(addEndTimes=addEndTimes,
+                                useMixedNumerals=useMixedNumerals,
+                                addBreaks=False,
+                                addIndent=False)
 
     # --------------------------------------------------------------------------
     # display methods; in the same manner as show() and write()
@@ -3188,7 +3185,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         '''
         return self.iter.getElementsByGroup(groupFilterList, returnClone=False)
 
-    def getElementById(self, elementId, classFilter=None) -> Optional[base.Music21Object]:
+    def getElementById(self, elementId) -> Optional[base.Music21Object]:
         '''
         Returns the first encountered element for a given id. Return None
         if no match. Note: this uses the id attribute stored on elements,
@@ -3218,10 +3215,10 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         True
         >>> ew.activeSite is a
         True
+
+        Changed in v7. -- remove classFilter.
         '''
         sIterator = self.iter.addFilter(filters.IdFilter(elementId))
-        if classFilter is not None:
-            sIterator = sIterator.getElementsByClass(classFilter)
         for e in sIterator:
             return e
         return None
@@ -3230,9 +3227,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         self,
         offsetStart,
         offsetEnd=None,
-
         *,
-
         includeEndBoundary=True,
         mustFinishInSpan=False,
         mustBeginInSpan=True,
@@ -3886,6 +3881,44 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         <music21.stream.Measure 8 offset=0.0>
         <music21.stream.Measure 9 offset=4.0>
 
+
+        If a stream has measure suffixes, then Streams having that suffix or no suffix
+        are returned.
+
+        >>> p = stream.Part()
+        >>> mSuffix3 = stream.Measure(number=3)
+        >>> mSuffix4 = stream.Measure(number=4)
+        >>> mSuffix4a = stream.Measure(number=4)
+        >>> mSuffix4a.numberSuffix = 'a'
+        >>> mSuffix4b = stream.Measure(number=4)
+        >>> mSuffix4b.numberSuffix = 'b'
+        >>> mSuffix5 = stream.Measure(number=5)
+        >>> mSuffix5a = stream.Measure(number=5)
+        >>> mSuffix5a.numberSuffix = 'a'
+        >>> mSuffix6 = stream.Measure(number=6)
+        >>> p.append([mSuffix3, mSuffix4, mSuffix4a, mSuffix4b, mSuffix5, mSuffix5a, mSuffix6])
+        >>> suffixExcerpt = p.measures('4b', 6)
+        >>> suffixExcerpt.show('text')
+        {0.0} <music21.stream.Measure 4 offset=0.0>
+        <BLANKLINE>
+        {0.0} <music21.stream.Measure 4b offset=0.0>
+        <BLANKLINE>
+        {0.0} <music21.stream.Measure 5 offset=0.0>
+        <BLANKLINE>
+        {0.0} <music21.stream.Measure 5a offset=0.0>
+        <BLANKLINE>
+        {0.0} <music21.stream.Measure 6 offset=0.0>
+        <BLANKLINE>
+        >>> suffixExcerpt2 = p.measures(3, '4a')
+        >>> suffixExcerpt2.show('text')
+        {0.0} <music21.stream.Measure 3 offset=0.0>
+        <BLANKLINE>
+        {0.0} <music21.stream.Measure 4 offset=0.0>
+        <BLANKLINE>
+        {0.0} <music21.stream.Measure 4a offset=0.0>
+        <BLANKLINE>
+
+
         Changed in v.7 -- If `gatherSpanners` is True or GatherSpanners.ALL (default),
         then just the spanners pertaining to the requested measure region
         are provided, rather than the entire bundle from the source.
@@ -3898,6 +3931,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         >>> len(beachIn.spannerBundle)
         93
 
+        Changed in v.7 -- does not create measures automatically.
+
         OMIT_FROM_DOCS
 
         Ensure that layout.StaffGroup objects are present:
@@ -3934,12 +3969,6 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         srcObj = self
 
         mStreamIter = self.getElementsByClass('Measure')
-        # if we have no Measures defined, call makeNotation
-        # this will  return a deepcopy of all objects
-        if not mStreamIter:
-            srcObj = self.makeNotation(inPlace=False)
-            # need to set srcObj to this new stream
-            mStreamIter = srcObj.getElementsByClass('Measure')
 
         # FIND THE CORRECT ORIGINAL MEASURE OBJECTS
         # for indicesNotNumbers, this is simple...
@@ -4071,6 +4100,12 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
         >>> print(a.parts[0].measure(99))
         None
+
+        OMIT_FROM_DOCS
+
+        >>> sf = a.parts[0].flat
+        >>> sf.measure(2) is None
+        True
         '''
         if not isinstance(measureNumber, str) and measureNumber < 0:
             indicesNotNumbers = True
@@ -4103,6 +4138,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             return None
 
     def template(self,
+                 *,
                  fillWithRests=True,
                  removeClasses=None,
                  retainVoices=True,
@@ -4255,6 +4291,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         return to the original objects), using .template() is several
         times faster than a deepcopy of the stream (about 4x faster
         on bwv66.6)
+
+        Changed in v7. -- all arguments are keyword only.
         '''
         out = self.cloneEmpty(derivationMethod='template')
         if removeClasses is None:
@@ -4286,7 +4324,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
                                     retainVoices=retainVoices)
                 if elOffset != OffsetSpecial.AT_END:
                     out.coreInsert(elOffset, outEl)
-                else:
+                else:  # pragma: no cover
+                    # should not have streams stored at end.
                     out.coreStoreAtEnd(outEl)
 
             elif (removeClasses is True
@@ -4315,7 +4354,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
     def measureOffsetMap(self, classFilterList=None):
         '''
-        If this Stream contains Measures, provide an OrderedDict
+        If this Stream contains Measures, returns an OrderedDict
         whose keys are the offsets of the start of each measure
         and whose values are a list of references
         to the :class:`~music21.stream.Measure` objects that start
@@ -4347,10 +4386,16 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         >>> chorale = corpus.parse('bach/bwv324.xml')
         >>> alto = chorale.parts['alto']
         >>> altoMeasures = alto.measureOffsetMap()
+        >>> altoMeasures
+        OrderedDict([(0.0, [<music21.stream.Measure 1 offset=0.0>]),
+                     (4.0, [<music21.stream.Measure 2 offset=4.0>]),
+                     (8.0, [<music21.stream.Measure 3 offset=8.0>]),
+                     ...
+                     (38.0, [<music21.stream.Measure 9 offset=38.0>])])
         >>> list(altoMeasures.keys())
         [0.0, 4.0, 8.0, 12.0, 16.0, 20.0, 24.0, 34.0, 38.0]
 
-        altoMeasures is a dictionary (hash) of the measures
+        altoMeasures is a dictionary of the measures
         that are found in the alto part, so we can get
         the measure beginning on offset 4.0 (measure 2)
         and display it (though it's the only measure
@@ -4367,17 +4412,22 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         {3.0} <music21.note.Note F#>
 
         Example 2: How to get all the measures from all parts (not the
-        most efficient way, but it works!).  Note that
-        you first need to call semiFlat, which finds all containers
-        (and other elements) nested inside all parts:
-
-        >>> choraleSemiFlat = chorale.semiFlat
-        >>> choraleMeasures = choraleSemiFlat.measureOffsetMap()
-        >>> choraleMeasures[4.0]
-        [<music21.stream.Measure 2 offset=4.0>,
-         <music21.stream.Measure 2 offset=4.0>,
-         <music21.stream.Measure 2 offset=4.0>,
-         <music21.stream.Measure 2 offset=4.0>]
+        most efficient way, but it works!):
+
+        >>> mom = chorale.measureOffsetMap()
+        >>> mom
+        OrderedDict([(0.0, [<music21.stream.Measure 1 offset=0.0>,
+                            <music21.stream.Measure 1 offset=0.0>,
+                            <music21.stream.Measure 1 offset=0.0>,
+                            <music21.stream.Measure 1 offset=0.0>]),
+                      (4.0, [<music21.stream.Measure 2 offset=4.0>,
+                             ...])])
+        >>> for m in mom[8.0]:
+        ...     print(m, m.getContextByClass('Part').id)
+        <music21.stream.Measure 3 offset=8.0> Soprano
+        <music21.stream.Measure 3 offset=8.0> Alto
+        <music21.stream.Measure 3 offset=8.0> Tenor
+        <music21.stream.Measure 3 offset=8.0> Bass
 
         OMIT_FROM_DOCS
         see important examples in testMeasureOffsetMap() and testMeasureOffsetMapPostTie()
@@ -4412,7 +4462,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
                 # 'reverse' here is a reverse sort, where oldest objects are returned
                 # first
                 m = e.getContextByClass('Measure')  # , sortByCreationTime='reverse')
-                if m is None:
+                if m is None:  # pragma: no cover
+                    # hard to think of a time this would happen...But...
                     continue
                 # assuming that the offset returns the proper offset context
                 # this is, the current offset may not be the stream that
@@ -4667,9 +4718,25 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         True
         >>> scSounding.recurse().notes[0].nameWithOctave
         'C3'
+
+        If 'atSoundingPitch' is unknown for this Stream and all of its parent Streams
+        then will raise a StreamException:
+
+        >>> s = stream.Score()
+        >>> p = stream.Part(id='partEmpty')
+        >>> s.append(p)
+        >>> p.toSoundingPitch()
+        Traceback (most recent call last):
+        music21.exceptions21.StreamException: atSoundingPitch is unknown: cannot transpose
+        >>> s.atSoundingPitch = False
+        >>> sp = p.toSoundingPitch()
+        >>> sp
+        <music21.stream.Part partEmpty>
+        >>> sp.derivation.origin is p
+        True
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('toSoundingPitch')
         else:
             returnObj = self
 
@@ -4731,7 +4798,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         'A4'
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('toWrittenPitch')
         else:
             returnObj = self
 
@@ -5035,7 +5102,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         if inPlace:
             returnStream = self
         else:
-            returnStream = copy.deepcopy(self)
+            returnStream = self.coreCopyAsDerivation('invertDiatonic')
 
         keySigSearch = returnStream.recurse().getElementsByClass(key.KeySignature)
 
@@ -5251,7 +5318,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         self.coreElementsChanged()
 
     def extractContext(self, searchElement, before=4.0, after=4.0,
-                       maxBefore=None, maxAfter=None, forceOutputClass=None):
+                       maxBefore=None, maxAfter=None):
         '''
         Extracts elements around the given element within (before)
         quarter notes and (after) quarter notes (default 4), and
@@ -5270,6 +5337,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         {6.0} <music21.note.Note B->
         {8.0} <music21.note.Note C>
 
+        Changed in v7. -- forceOutputClass removed.
+
         OMIT_FROM_DOCS
         TODO: maxBefore -- maximum number of elements to return before; etc.
         TODO: use .template to get new Stream
@@ -5278,14 +5347,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         Perhaps better is extractNeighbors?
 
         '''
-        if forceOutputClass is None:
-            display = self.__class__()
-        else:
-            # is this ever used? prevents using .cloneEmpty('extractContext')
-            display = forceOutputClass()
-
-        display.derivation.origin = self
-        display.derivation.method = 'extractContext'
+        display = self.cloneEmpty('extractContext')
 
         found = None
         foundOffset = 0
@@ -5454,9 +5516,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             # a Stream
             # returnObj = Stream()
             # returnObj = self.__class__()  # for output
-            returnObj = copy.deepcopy(self)
-            returnObj.derivation.origin = self
-            returnObj.derivation.method = 'makeChords'
+            returnObj = self.coreCopyAsDerivation('makeChords')
         else:
             returnObj = self
 
@@ -6207,7 +6267,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         All arguments are keyword only.
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('makeAccidentals')
         else:
             returnObj = self
 
@@ -6347,7 +6407,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         if inPlace:
             returnStream = self
         else:
-            returnStream = copy.deepcopy(self)
+            returnStream = self.coreCopyAsDerivation('makeNotation')
 
         # if 'finalBarline' in subroutineKeywords:
         #     lastBarlineType = subroutineKeywords['finalBarline']
@@ -6492,7 +6552,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         '''
 
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('extendDuration')
         else:
             returnObj = self
 
@@ -6624,9 +6684,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         '''
         # environLocal.printDebug(['calling stripTies'])
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
-            returnObj.derivation.method = 'stripTies'
-            returnObj.setDerivationMethod('stripTies', recurse=True)
+            returnObj = self.coreCopyAsDerivation('stripTies')
         else:
             returnObj = self
 
@@ -8289,9 +8347,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         '''
         # only change the copy
         if not inPlace:
-            post = copy.deepcopy(self)
-            post.derivation.method = 'transpose'
-            post.setDerivationMethod('transpose', recurse=True)
+            post = self.coreCopyAsDerivation('transpose')
         else:
             post = self
         # for p in post.pitches:  # includes chords
@@ -8373,9 +8429,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             raise StreamException('amountToScale must be greater than zero')
 
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
-            returnObj.derivation.method = 'scaleOffsets'
-            returnObj.setDerivationMethod('scaleOffsets', recurse=True)
+            returnObj = self.coreCopyAsDerivation('scaleOffsets')
         else:
             returnObj = self
 
@@ -8428,9 +8482,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             raise StreamException('amountToScale must be greater than zero')
 
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
-            returnObj.derivation.method = 'scaleDurations'
-            returnObj.setDerivationMethod('scaleDurations', recurse=True)
+            returnObj = self.coreCopyAsDerivation('scaleDurations')
         else:
             returnObj = self
 
@@ -8479,9 +8531,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         if not amountToScale > 0:
             raise StreamException('amountToScale must be greater than zero')
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
-            returnObj.derivation.method = 'augmentOrDiminish'
-            returnObj.setDerivationMethod('augmentOrDiminish', recurse=True)
+            returnObj = self.coreCopyAsDerivation('augmentOrDiminish')
         else:
             returnObj = self
 
@@ -8620,9 +8670,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
         # TODO: Use new filters...
         if inPlace is False:
-            returnStream = copy.deepcopy(self)
-            returnStream.derivation.method = 'quantize'
-            returnStream.setDerivationMethod('quantize', recurse=True)
+            returnStream = self.coreCopyAsDerivation('quantize')
 
         else:
             returnStream = self
@@ -8733,7 +8781,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
 
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('sliceByQuarterLengths')
         else:
             returnObj = self
 
@@ -8810,7 +8858,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         # and use the approximateGCD to get a min duration; then, call sliceByQuarterLengths
 
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('sliceByGreatestDivisor')
         else:
             returnObj = self
 
@@ -8859,7 +8907,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         [(0.0, 1.0), (1.0, 1.0), (2.0, 1.0), (3.0, 1.0)]
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('sliceAtOffsets')
         else:
             returnObj = self
 
@@ -8935,11 +8983,11 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         Slice all elements in the Stream that have a Duration at
         the offsets determined to be the beat from the local TimeSignature.
 
-        TODO: return None if inPlace is True
+        Changed in v7. -- return None if inPlace is True
         '''
 
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('sliceByBeat')
         else:
             returnObj = self
 
@@ -8977,7 +9025,8 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
                                  inPlace=True,
                                  displayTiedAccidentals=displayTiedAccidentals)
 
-        return returnObj
+        if not inPlace:
+            return returnObj
 
     # --------------------------------------------------------------------------
     # get boolean information from the Stream
@@ -10247,7 +10296,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
         # produce the optimal voice assignment based on context (register
         # chord formation, etc
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('makeVoices')
         else:
             returnObj = self
         # must be sorted
@@ -11073,7 +11122,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             {4.0} <music21.bar.Barline type=final>
         '''
         if not inPlace:  # make a copy if inPlace is False
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('activateVariants')
         else:
             returnObj = self
 
@@ -11931,7 +11980,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
             returnObj = self
             returnPart = containedPart
         else:
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('showVariantAsOssialikePart')
             containedPartIndex = self.parts.stream().index(containedPart)
             returnPart = returnObj.parts[containedPartIndex]
 
@@ -12848,7 +12897,7 @@ class Part(Stream):
         TODO: by default inPlace should be False
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('makeAccidentals')
         else:
             returnObj = self
         # process make accidentals for each measure
@@ -13222,8 +13271,9 @@ class Score(Stream):
         Overrides method defined on Stream.
         '''
         if not inPlace:  # make a copy
-            returnObj = copy.deepcopy(self)
+            returnObj = self.coreCopyAsDerivation('sliceByGreatestDivisor')
         else:
+
             returnObj = self
 
         # find greatest divisor for each measure at a time
@@ -13462,7 +13512,7 @@ class Score(Stream):
         if inPlace:
             returnStream = self
         else:
-            returnStream = copy.deepcopy(self)
+            returnStream = self.coreCopyAsDerivation('makeNotation')
         returnStream.coreGatherMissingSpanners()  # get spanners needed but not here!
 
         # do not assume that we have parts here
diff --git a/music21/stream/core.py b/music21/stream/core.py
index 750ad1f4f..2a9ea40b0 100644
--- a/music21/stream/core.py
+++ b/music21/stream/core.py
@@ -21,6 +21,7 @@ remain stable.
 
 All functions here will eventually begin with `.core`.
 '''
+import copy
 from typing import List, Dict, Union, Tuple, Optional
 from fractions import Fraction
 import unittest
@@ -290,6 +291,30 @@ class StreamCoreMixin:
             if keepIndex and indexCache is not None:
                 self._cache['index'] = indexCache
 
+    def coreCopyAsDerivation(self, methodName: str, *, recurse=True, deep=True):
+        '''
+        Make a copy of this stream with the proper derivation set.
+
+        >>> s = stream.Stream()
+        >>> n = note.Note()
+        >>> s.append(n)
+        >>> s2 = s.coreCopyAsDerivation('exampleCopy')
+        >>> s2.derivation.method
+        'exampleCopy'
+        >>> s2.derivation.origin is s
+        True
+        >>> s2[0].derivation.method
+        'exampleCopy'
+        '''
+        if deep:
+            post = copy.deepcopy(self)
+        else:  # pragma: no cover
+            post = copy.copy(self)
+        post.derivation.method = methodName
+        if recurse and deep:
+            post.setDerivationMethod(methodName, recurse=True)
+        return post
+
     def coreHasElementByMemoryLocation(self, objId: int) -> bool:
         '''
         NB -- a "core" stream method that is not necessary for most users. use hasElement(obj)


Test patch:
diff --git a/music21/braille/runAllBrailleTests.py b/music21/braille/runAllBrailleTests.py
index 671678ad6..db16dcec1 100644
--- a/music21/braille/runAllBrailleTests.py
+++ b/music21/braille/runAllBrailleTests.py
@@ -26,7 +26,7 @@ from music21 import braille
 
 current_executable = sys.executable
 
-def runTest():
+def runTest():  # pragma: no cover
     savedStderr = sys.stderr
     totalTests = 0
     hadError = False
diff --git a/music21/test/testStream.py b/music21/test/testStream.py
index f2408176b..2fbe076cb 100644
--- a/music21/test/testStream.py
+++ b/music21/test/testStream.py
@@ -16,6 +16,7 @@ import copy
 import music21
 from music21.note import GeneralNote
 
+from music21.stream import StreamException
 from music21.stream import Stream
 from music21.stream import Voice
 from music21.stream import Measure
@@ -28,6 +29,7 @@ from music21 import beam
 from music21 import chord
 from music21 import clef
 from music21 import common
+from music21 import corpus
 from music21 import duration
 from music21 import interval
 from music21 import key
@@ -172,7 +174,6 @@ class TestExternal(unittest.TestCase):  # pragma: no cover
         This demonstrates obtaining slices from a stream and layering
         them into individual parts.
         '''
-        from music21 import corpus
         k155_score = corpus.parse('mozart/k155', 2)
         start_measure = 0
         end_measure = 16
@@ -284,7 +285,7 @@ class TestExternal(unittest.TestCase):  # pragma: no cover
 # ------------------------------------------------------------------------------
 class Test(unittest.TestCase):
 
-    def testAdd(self):
+    def testIsFlat(self):
         a = Stream()
         for dummy in range(5):
             a.insert(0, music21.Music21Object())
@@ -294,6 +295,14 @@ class Test(unittest.TestCase):
         a[3] = Stream()
         self.assertFalse(a.isFlat)
 
+    def testAppendFails(self):
+        a = Stream()
+        others = [music21.Music21Object(), 'hello']
+        with self.assertRaises(StreamException) as context:
+            a.append(others)
+        self.assertIn("'hello'", str(context.exception))
+
+
     def testSort(self):
         s = Stream()
         s.repeatInsert(note.Note('C#'), [0.0, 2.0, 4.0])
@@ -396,10 +405,9 @@ class Test(unittest.TestCase):
         self.assertEqual(st1.flat.sorted[0].offset, 22.0)
 
     def testStreamExceptionsOnAssert(self):
-        from music21 import stream
-        with self.assertRaises(stream.StreamException):
+        with self.assertRaises(StreamException):
             n1 = note.Note()
-            stream.Stream([n1, 0])
+            Stream([n1, 0])
 
     def testStreamRecursion(self):
         srcStream = Stream()
@@ -589,7 +597,7 @@ class Test(unittest.TestCase):
         s.insert(8, meter.TimeSignature('3/4'))
         self.assertEqual(len(s.flat.notes), 80)
 
-        from music21 import corpus, converter
+        from music21 import converter
         thisWork = corpus.getWork('corelli/opus3no1/1grave')
         a = converter.parse(thisWork)
 
@@ -617,12 +625,10 @@ class Test(unittest.TestCase):
         Part and Measure do not match, and instead music21.stream.Part has to be
         employed instead.
         '''
-        from music21 import stream  # needed to do fully-qualified isinstance name checking
-        from music21 import corpus
         a = corpus.parse('corelli/opus3no1/1grave')
         # test basic activeSite relationships
         b = a[8]
-        self.assertIsInstance(b, stream.Part)
+        self.assertIsInstance(b, Part)
         self.assertEqual(b.activeSite, a)
 
         # this, if called, actively destroys the activeSite relationship!
@@ -635,7 +641,7 @@ class Test(unittest.TestCase):
         # NOTE: this is dependent on raw element order, and might change
         # due to importing changes
         # b.show('t')
-        self.assertIsInstance(b[15], stream.Measure)
+        self.assertIsInstance(b[15], Measure)
         self.assertIs(b[8].activeSite, b)  # measures activeSite should be part
 
         # a different test derived from a TestExternal
@@ -670,7 +676,7 @@ class Test(unittest.TestCase):
         self.assertEqual(n.getOffsetBySite(a), 10)
 
     def testExtractedNoteAssignLyric(self):
-        from music21 import converter, corpus, text
+        from music21 import converter, text
         a = converter.parse(corpus.getWork('corelli/opus3no1/1grave'))
         b = a.parts[1]
         c = b.flat
@@ -684,7 +690,6 @@ class Test(unittest.TestCase):
         '''
         Test getting an instrument from an mxl file
         '''
-        from music21 import corpus
 
         # manually set activeSite to associate
         a = corpus.parse('corelli/opus3no1/1grave.xml')
@@ -1210,7 +1215,7 @@ class Test(unittest.TestCase):
         '''Test stripTies using the Score method
         '''
 
-        from music21 import corpus, converter
+        from music21 import converter
         from music21.musicxml import testPrimitive
 
         # This score has 4 parts, each with eight measures, and 2 half-notes
@@ -1273,7 +1278,7 @@ class Test(unittest.TestCase):
         Test whether strip ties merges some chords that are the same and
         some that are not.
         '''
-        from music21 import stream, tie
+        from music21 import tie
         ch0 = chord.Chord('C4 E4 G4')
         ch1 = chord.Chord('C4 E4 G4')
         ch2 = chord.Chord('C3 E3 G3')
@@ -1281,14 +1286,14 @@ class Test(unittest.TestCase):
         ch4 = chord.Chord('D4 F#4 A4')
         ch5 = chord.Chord('D4 F#4')
         chords = [ch0, ch1, ch2, ch3, ch4, ch5]
-        p = stream.Part()
+        p = Part()
         p.append(meter.TimeSignature('1/4'))
         for i in range(6):
             c = chords[i]
             if not i % 2:
                 t = tie.Tie('start')
                 c.tie = t
-            m = stream.Measure(number=i + 1)
+            m = Measure(number=i + 1)
             m.append(c)
             p.append(m)
         p2 = p.stripTies(matchByPitch=True)
@@ -1348,7 +1353,6 @@ class Test(unittest.TestCase):
     #    assert trimPlayingWhileSounding[1].duration.quarterLength == 3.5
 
     def testMeasureRange(self):
-        from music21 import corpus
         a = corpus.parse('bach/bwv324.xml')
         b = a.parts[3].measures(4, 6)
         self.assertEqual(len(b.getElementsByClass('Measure')), 3)
@@ -1410,7 +1414,6 @@ class Test(unittest.TestCase):
         # b.show()
 
     def testMeasureOffsetMap(self):
-        from music21 import corpus
         a = corpus.parse('bach/bwv324.xml')
 
         mOffsetMap = a.parts[0].measureOffsetMap()
@@ -1462,7 +1465,6 @@ class Test(unittest.TestCase):
                          [0.0, 4.0, 8.0, 12.0, 16.0, 20.0, 24.0, 34.0, 38.0])
 
     def testMeasureOffsetMapPostTie(self):
-        from music21 import corpus, stream
 
         a = corpus.parse('bach/bwv4.8')
         # alto line syncopated/tied notes across bars
@@ -1487,15 +1489,15 @@ class Test(unittest.TestCase):
         self.assertEqual(len(altoPostTie.flat.notesAndRests), countedAltoNotes - 2)
 
         # we can still get measure numbers:
-        mNo = altoPostTie.flat.notesAndRests[3].getContextByClass(stream.Measure).number
+        mNo = altoPostTie.flat.notesAndRests[3].getContextByClass(Measure).number
         self.assertEqual(mNo, 1)
-        mNo = altoPostTie.flat.notesAndRests[8].getContextByClass(stream.Measure).number
+        mNo = altoPostTie.flat.notesAndRests[8].getContextByClass(Measure).number
         self.assertEqual(mNo, 2)
-        mNo = altoPostTie.flat.notesAndRests[15].getContextByClass(stream.Measure).number
+        mNo = altoPostTie.flat.notesAndRests[15].getContextByClass(Measure).number
         self.assertEqual(mNo, 4)
 
         # can we get an offset Measure map by looking for measures
-        post = altoPostTie.measureOffsetMap(stream.Measure)
+        post = altoPostTie.measureOffsetMap(Measure)
         # yes, retainContainers defaults to True
         self.assertEqual(list(post.keys()), correctMeasureOffsetMap)
 
@@ -1895,12 +1897,11 @@ class Test(unittest.TestCase):
 
     def testMakeRestsB(self):
         # test makeRests fillGaps
-        from music21 import stream
-        s = stream.Stream()
-        m1 = stream.Measure()
+        s = Stream()
+        m1 = Measure()
         m1.timeSignature = meter.TimeSignature('4/4')
         m1.insert(2, note.Note())
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.insert(1, note.Note())
         self.assertTrue(m2.isSorted)
 
@@ -1959,7 +1960,6 @@ class Test(unittest.TestCase):
         Testing making measures of various sizes with a supplied single element meter stream.
         This illustrates an approach to partitioning elements by various sized windows.
         '''
-        from music21 import corpus
         sBach = corpus.parse('bach/bwv324.xml')
         meterStream = Stream()
         meterStream.insert(0, meter.TimeSignature('2/4'))
@@ -1999,8 +1999,7 @@ class Test(unittest.TestCase):
     def testMakeMeasuresWithBarlines(self):
         '''Test makeMeasures with optional barline parameters.
         '''
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(quarterLength=0.5), 20)
         s.insert(0, meter.TimeSignature('5/8'))
 
@@ -2069,9 +2068,7 @@ class Test(unittest.TestCase):
         self.assertEqual(n1.activeSite, None)
 
     def testRemoveByClass(self):
-        from music21 import stream
-
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(clef.BassClef(), 2)
         s.repeatAppend(note.Note(), 2)
         s.repeatAppend(clef.TrebleClef(), 2)
@@ -2110,7 +2107,6 @@ class Test(unittest.TestCase):
         self.assertEqual([s[0], s[1]], [n3, n1])
 
     def testReplaceA1(self):
-        from music21 import corpus
         sBach = corpus.parse('bach/bwv324.xml')
         partSoprano = sBach.parts.first()
 
@@ -2157,7 +2153,6 @@ class Test(unittest.TestCase):
         self.assertEqual(s3[0].getOffsetBySite(s3), 30)
 
     def testReplaceDerived(self):
-        from music21 import corpus
         qj = corpus.parse('ciconia/quod_jactatur').parts[0].measures(1, 2)
         qj.id = 'measureExcerpt'
 
@@ -2370,7 +2365,6 @@ class Test(unittest.TestCase):
         self.assertEqual(c1.pitches[2].accidental, None)
 
     def testMakeAccidentalsB(self):
-        from music21 import corpus
         s = corpus.parse('monteverdi/madrigal.5.3.rntxt')
         m34 = s.parts[0].getElementsByClass('Measure')[33]
         c = m34.getElementsByClass('Chord')
@@ -2390,18 +2384,16 @@ class Test(unittest.TestCase):
         self.assertEqual(str(c[0].pitches[0].accidental), 'None')
 
     def testMakeAccidentalsC(self):
-        from music21 import stream
-
         # this isolates the case where a new measure uses an accidental
         # that was used in a past measure
 
-        m1 = stream.Measure()
+        m1 = Measure()
         m1.repeatAppend(note.Note('f4'), 2)
         m1.repeatAppend(note.Note('f#4'), 2)
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.repeatAppend(note.Note('f#4'), 4)
 
-        ex = stream.Part()
+        ex = Part()
         ex.append([m1, m2])
         # without applying make accidentals, all sharps are shown
         self.assertEqual(len(ex.flat.notes), 8)
@@ -2423,7 +2415,7 @@ class Test(unittest.TestCase):
         # need the second true b/c it is the start of a new measure
         self.assertEqual(display, [True, False, True, False, False, False])
 
-        p = stream.Part()
+        p = Part()
         p.insert(0, meter.TimeSignature('2/4'))
         tuplet1 = note.Note('E-4', quarterLength=1 / 3)
         tuplet2 = note.Note('F#4', quarterLength=2 / 3)
@@ -2439,9 +2431,8 @@ class Test(unittest.TestCase):
                                    1, 0, 0])
 
     def testMakeAccidentalsD(self):
-        from music21 import stream
-        p1 = stream.Part()
-        m1 = stream.Measure()
+        p1 = Part()
+        m1 = Measure()
         m1.append(meter.TimeSignature('4/4'))
         m1.append(note.Note('C#', type='half'))
         m1.append(note.Note('C#', type='half'))
@@ -2525,8 +2516,6 @@ class Test(unittest.TestCase):
             self.assertFalse(n.pitch.accidental.displayStatus)
 
     def testScaleOffsetsBasic(self):
-        from music21 import stream
-
         def procCompare(s_inner, scalar, match):
             oListSrc = [e.offset for e in s_inner]
             oListSrc.sort()
@@ -2541,7 +2530,7 @@ class Test(unittest.TestCase):
         # test equally spaced half notes starting at zero
         n = note.Note()
         n.quarterLength = 2
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(n, 10)
 
         # provide start of resulting values
@@ -2555,7 +2544,7 @@ class Test(unittest.TestCase):
         # test equally spaced quarter notes start at non-zero
         n = note.Note()
         n.quarterLength = 1
-        s = stream.Stream()
+        s = Stream()
         s.repeatInsert(n, list(range(100, 110)))
 
         procCompare(s, 1, [100, 101, 102, 103])
@@ -2566,7 +2555,7 @@ class Test(unittest.TestCase):
         procCompare(s, 0.25, [100, 100.25, 100.5, 100.75])
 
         # test non equally spaced notes starting at zero
-        s = stream.Stream()
+        s = Stream()
         n1 = note.Note()
         n1.quarterLength = 1
         s.repeatInsert(n, list(range(0, 30, 3)))
@@ -2579,7 +2568,7 @@ class Test(unittest.TestCase):
         procCompare(s, 2, [0.0, 2.0, 6.0, 8.0, 12.0, 14.0])
 
         # test non equally spaced notes starting at non-zero
-        s = stream.Stream()
+        s = Stream()
         n1 = note.Note()
         n1.quarterLength = 1
         s.repeatInsert(n, list(range(100, 130, 3)))
@@ -2593,13 +2582,11 @@ class Test(unittest.TestCase):
         procCompare(s, 6, [100.0, 106.0, 118.0, 124.0, 136.0, 142.0])
 
     def testScaleOffsetsBasicInPlaceA(self):
-        from music21 import stream
-
         def procCompare(scalar, match):
             # test equally spaced half notes starting at zero
             n = note.Note()
             n.quarterLength = 2
-            s = stream.Stream()
+            s = Stream()
             s.repeatAppend(n, 10)
 
             oListSrc = [e.offset for e in s]
@@ -2620,13 +2607,11 @@ class Test(unittest.TestCase):
         procCompare(0.25, [0.0, 0.5, 1.0, 1.5])
 
     def testScaleOffsetsBasicInPlaceB(self):
-        from music21 import stream
-
         def procCompare(scalar, match):
             # test equally spaced quarter notes start at non-zero
             n = note.Note()
             n.quarterLength = 1
-            s = stream.Stream()
+            s = Stream()
             s.repeatInsert(n, list(range(100, 110)))
 
             oListSrc = [e.offset for e in s]
@@ -2646,11 +2631,9 @@ class Test(unittest.TestCase):
         procCompare(0.25, [100, 100.25, 100.5, 100.75])
 
     def testScaleOffsetsBasicInPlaceC(self):
-        from music21 import stream
-
         def procCompare(scalar, match):
             # test non equally spaced notes starting at zero
-            s = stream.Stream()
+            s = Stream()
             n1 = note.Note()
             n1.quarterLength = 1
             s.repeatInsert(n1, list(range(0, 30, 3)))
@@ -2673,11 +2656,9 @@ class Test(unittest.TestCase):
         procCompare(2, [0.0, 2.0, 6.0, 8.0, 12.0, 14.0])
 
     def testScaleOffsetsBasicInPlaceD(self):
-        from music21 import stream
-
         def procCompare(scalar, match):
             # test non equally spaced notes starting at non-zero
-            s = stream.Stream()
+            s = Stream()
             n1 = note.Note()
             n1.quarterLength = 1
             s.repeatInsert(n1, list(range(100, 130, 3)))
@@ -2701,8 +2682,6 @@ class Test(unittest.TestCase):
         procCompare(6, [100.0, 106.0, 118.0, 124.0, 136.0, 142.0])
 
     def testScaleOffsetsNested(self):
-        from music21 import stream
-
         def scaleOffsetMap(s):  # lists of offsets, with lists of lists
             post = []
             for e in s:
@@ -2730,12 +2709,12 @@ class Test(unittest.TestCase):
         # test equally spaced half notes starting at zero
         n1 = note.Note()
         n1.quarterLength = 2
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.repeatAppend(n1, 4)
 
         n2 = note.Note()
         n2.quarterLength = 0.5
-        s2 = stream.Stream()
+        s2 = Stream()
         s2.repeatAppend(n2, 4)
         s1.append(s2)
 
@@ -2760,12 +2739,12 @@ class Test(unittest.TestCase):
         # test unequally spaced notes starting at non-zero
         n1 = note.Note()
         n1.quarterLength = 1
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.repeatInsert(n1, [10, 14, 15, 17])
 
         n2 = note.Note()
         n2.quarterLength = 9.5
-        s2 = stream.Stream()
+        s2 = Stream()
         s2.repeatInsert(n2, [40, 40.5, 41, 41.5])
         self.assertEqual(s2.highestTime, 51)
         s1.append(s2)
@@ -2900,7 +2879,6 @@ class Test(unittest.TestCase):
     def testAugmentOrDiminishHighestTimes(self):
         '''Need to make sure that highest offset and time are properly updated
         '''
-        from music21 import corpus
         src = corpus.parse('bach/bwv324.xml')
         # get some measures of the soprano; just get the notes
         ex = src.parts[0].flat.notesAndRests.stream()[0:30]
@@ -2927,7 +2905,6 @@ class Test(unittest.TestCase):
     def testAugmentOrDiminishCorpus(self):
         '''Extract phrases from the corpus and use for testing
         '''
-        from music21 import corpus
         # first method: iterating through notes
         src = corpus.parse('bach/bwv324.xml')
         # get some measures of the soprano; just get the notes
@@ -2961,9 +2938,7 @@ class Test(unittest.TestCase):
 
     def testMeasureBarDurationProportion(self):
         from fractions import Fraction
-        from music21 import stream
-
-        m = stream.Measure()
+        m = Measure()
         m.timeSignature = meter.TimeSignature('3/4')
         n = note.Note('B--2')
         n.quarterLength = 1
@@ -2981,7 +2956,7 @@ class Test(unittest.TestCase):
 #         self.assertAlmostEqual(m.barDurationProportion(), 1.0, 4)
 #         self.assertAlmostEqual(m.highestOffset, 2.0, 4)
 
-        m = stream.Measure()
+        m = Measure()
         m.timeSignature = meter.TimeSignature('5/4')
         n1 = note.Note()
         n1.quarterLength = 0.5
@@ -3214,7 +3189,6 @@ class Test(unittest.TestCase):
         unused_mx = GEX.parse(s).decode('utf-8')
 
     def testYieldContainers(self):
-        from music21 import stream
         n1 = note.Note()
         n1.id = 'n(1a)'
         n2 = note.Note()
@@ -3224,31 +3198,31 @@ class Test(unittest.TestCase):
         n4 = note.Note()
         n4.id = 'n4(3b)'
 
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.id = '1a'
         s1.append(n1)
 
-        s2 = stream.Stream()
+        s2 = Stream()
         s2.id = '2a'
-        s3 = stream.Stream()
+        s3 = Stream()
         s3.id = '2b'
         s3.append(n2)
-        s4 = stream.Stream()
+        s4 = Stream()
         s4.id = '2c'
 
-        s5 = stream.Stream()
+        s5 = Stream()
         s5.id = '3a'
-        s6 = stream.Stream()
+        s6 = Stream()
         s6.id = '3b'
         s6.append(n3)
         s6.append(n4)
-        s7 = stream.Stream()
+        s7 = Stream()
         s7.id = '3c'
-        s8 = stream.Stream()
+        s8 = Stream()
         s8.id = '3d'
-        s9 = stream.Stream()
+        s9 = Stream()
         s9.id = '3e'
-        s10 = stream.Stream()
+        s10 = Stream()
         s10.id = '3f'
 
         # environLocal.printDebug(['s1, s2, s3, s4', s1, s2, s3, s4])
@@ -3679,7 +3653,6 @@ class Test(unittest.TestCase):
         self.assertEqual(s.flat.notes[-1].editorial.quarterLengthQuantizationError, .125 - .5)
 
     def testAnalyze(self):
-        from music21 import corpus
 
         s = corpus.parse('bach/bwv66.6')
 
@@ -3928,9 +3901,8 @@ class Test(unittest.TestCase):
     def testMakeNotationB(self):
         '''Testing voices making routines within make notation
         '''
-        from music21 import stream
         from music21.instrument import Xylophone
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, Xylophone())
         s.insert(0, note.Note('C4', quarterLength=8))
         s.repeatInsert(note.Note('b-4', quarterLength=0.5), [x * 0.5 for x in range(16)])
@@ -3956,8 +3928,7 @@ class Test(unittest.TestCase):
     def testMakeNotationC(self):
         '''Test creating diverse, overlapping durations and notes
         '''
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         for dur in [0.5, 1.5, 3]:
             for offset in [0, 1.5, 4, 6]:
                 # create a midi pitch value from duration
@@ -3974,11 +3945,9 @@ class Test(unittest.TestCase):
     def testMakeNotationScoreA(self):
         '''Test makeNotation on Score objects
         '''
-        from music21 import stream
-
-        s = stream.Score()
-        p1 = stream.Stream()
-        p2 = stream.Stream()
+        s = Score()
+        p1 = Stream()
+        p2 = Stream()
         for p in [p1, p2]:
             p.repeatAppend(note.Note(), 12)
             s.insert(0, p)
@@ -4002,11 +3971,9 @@ class Test(unittest.TestCase):
     def testMakeNotationScoreB(self):
         '''Test makeNotation on Score objects
         '''
-
-        from music21 import stream
-        s = stream.Score()
-        p1 = stream.Stream()
-        p2 = stream.Stream()
+        s = Score()
+        p1 = Stream()
+        p2 = Stream()
         for p in [p1, p2]:
             p.repeatAppend(note.Note(), 12)
             s.insert(0, p)
@@ -4017,7 +3984,7 @@ class Test(unittest.TestCase):
         self.assertFalse(s.getElementsByClass('Stream')[1].hasMeasures())
 
         # supply a meter stream
-        post = s.makeNotation(inPlace=False, meterStream=stream.Stream(
+        post = s.makeNotation(inPlace=False, meterStream=Stream(
             [meter.TimeSignature('3/4')]))
 
         self.assertTrue(post.hasPartLikeStreams())
@@ -4034,10 +4001,9 @@ class Test(unittest.TestCase):
     def testMakeNotationScoreC(self):
         '''Test makeNotation on Score objects
         '''
-        from music21 import stream
-        s = stream.Score()
-        p1 = stream.Stream()
-        p2 = stream.Stream()
+        s = Score()
+        p1 = Stream()
+        p2 = Stream()
         for p in [p1, p2]:
             p.repeatAppend(note.Note(), 12)
             s.insert(0, p)
@@ -4045,7 +4011,7 @@ class Test(unittest.TestCase):
         # create measures in the first part
         s.getElementsByClass('Stream').first().makeNotation(
             inPlace=True,
-            meterStream=stream.Stream([meter.TimeSignature('3/4')]))
+            meterStream=Stream([meter.TimeSignature('3/4')]))
 
         self.assertTrue(s.getElementsByClass('Stream')[0].hasMeasures())
         self.assertFalse(s.getElementsByClass('Stream')[1].hasMeasures())
@@ -4110,7 +4076,6 @@ class Test(unittest.TestCase):
 
     def testMakeTies(self):
 
-        from music21 import corpus
 
         def collectAccidentalDisplayStatus(s_inner):
             post = []
@@ -4299,7 +4264,6 @@ class Test(unittest.TestCase):
                           (15.0, 10), (20.0, 2), (22.0, 1.0)], match)
 
     def testMakeChordsBuiltA(self):
-        from music21 import stream
         # test with equal durations
         pitchCol = [('A2', 'C2'),
                     ('A#1', 'C-3', 'G5'),
@@ -4307,7 +4271,7 @@ class Test(unittest.TestCase):
         # try with different duration assignments; should always get
         # the same results
         for durCol in [[1, 1, 1], [0.5, 2, 3], [0.25, 0.25, 0.5], [6, 6, 8]]:
-            s = stream.Stream()
+            s = Stream()
             o = 0
             for i in range(len(pitchCol)):
                 ql = durCol[i]
@@ -4335,8 +4299,6 @@ class Test(unittest.TestCase):
         # s.show()
 
     def testMakeChordsBuiltB(self):
-        from music21 import stream
-
         n1 = note.Note('c2')
         n1.quarterLength = 2
         n2 = note.Note('d3')
@@ -4347,7 +4309,7 @@ class Test(unittest.TestCase):
         n4 = note.Note('f5')
         n4.quarterLength = 0.5
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, n1)
         s.insert(1, n2)  # overlapping, starting after n1 but finishing before
         s.insert(2, n3)
@@ -4375,7 +4337,7 @@ class Test(unittest.TestCase):
         n4 = note.Note('f5')
         n4.quarterLength = 1.5
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, n1)
         s.insert(1, n2)  # overlapping, starting after n1 but finishing before
         s.insert(2, n3)
@@ -4394,8 +4356,6 @@ class Test(unittest.TestCase):
 
     def testMakeChordsBuiltC(self):
         # test removal of redundant pitches
-        from music21 import stream
-
         n1 = note.Note('c2')
         n1.quarterLength = 0.5
         n2 = note.Note('c2')
@@ -4410,7 +4370,7 @@ class Test(unittest.TestCase):
         n6 = note.Note('f#4')
         n6.quarterLength = 0.5
 
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.insert(0, n1)
         s1.insert(0, n2)
         s1.insert(0, n3)
@@ -4435,9 +4395,7 @@ class Test(unittest.TestCase):
 
     def testMakeChordsBuiltD(self):
         # attempt to isolate case
-        from music21 import stream
-
-        p1 = stream.Part()
+        p1 = Part()
         p1.append([note.Note('G4', quarterLength=2),
                    note.Note('B4', quarterLength=2),
                    note.Note('C4', quarterLength=4),
@@ -4448,16 +4406,16 @@ class Test(unittest.TestCase):
 
                    ])
 
-        p2 = stream.Part()
+        p2 = Part()
         p2.append([note.Note('A3', quarterLength=4),
                    note.Note('F3', quarterLength=4), ])
 
-        p3 = stream.Part()
+        p3 = Part()
         p3.append([note.Rest(quarterLength=8),
                    note.Rest(quarterLength=4),
                    ])
 
-        s = stream.Score()
+        s = Score()
         s.insert([0, p1])
         s.insert([0, p2])
         s.insert([0, p3])
@@ -4469,7 +4427,6 @@ class Test(unittest.TestCase):
         # post.show()
 
     def testMakeChordsImported(self):
-        from music21 import corpus
         s = corpus.parse('bach/bwv66.6')
         # s.show()
         # using in place to get the stored flat version
@@ -4614,15 +4571,13 @@ class Test(unittest.TestCase):
         self.assertEqual(s.index(b1), 1)
 
     def testStoreAtEndFailures(self):
-        from music21 import stream
-
         s = Stream()
-        with self.assertRaises(stream.StreamException):
+        with self.assertRaises(StreamException):
             s.storeAtEnd(6)
 
         n = note.Note()
         n.duration.quarterLength = 2.0
-        with self.assertRaises(stream.StreamException):
+        with self.assertRaises(StreamException):
             s.storeAtEnd(n)
 
         # also test that lists work...
@@ -4630,7 +4585,7 @@ class Test(unittest.TestCase):
         s.storeAtEnd([b])
 
         # also test that element may not be in stream twice.
-        with self.assertRaises(stream.StreamException):
+        with self.assertRaises(StreamException):
             s.storeAtEnd([b])
 
         # test that element may not be in stream elements and at end.
@@ -4638,7 +4593,7 @@ class Test(unittest.TestCase):
         s.insert(0, b2)
         self.assertEqual(b2.offset, 0)
         self.assertEqual(s.elementOffset(b2, returnSpecial=True), 0)
-        with self.assertRaises(stream.StreamException):
+        with self.assertRaises(StreamException):
             s.storeAtEnd(b2)
 
     def testElementsHighestTimeB(self):
@@ -4703,8 +4658,6 @@ class Test(unittest.TestCase):
                          ['Note', 'Note', 'Barline', 'Barline', 'Treble8vaClef', 'TimeSignature'])
 
     def testSliceByQuarterLengthsBuilt(self):
-        from music21 import stream
-
         s = Stream()
         n1 = note.Note()
         n1.quarterLength = 1
@@ -4743,7 +4696,7 @@ class Test(unittest.TestCase):
                          [False, False, False, False, False, False, True, False, False, False])
 
         # cannot map 0.3333 into 0.5, so this raises an exception
-        self.assertRaises(stream.StreamException,
+        self.assertRaises(StreamException,
                           lambda: s.sliceByQuarterLengths(1 / 3, inPlace=False))
 
         post = s.sliceByQuarterLengths(1 / 6, inPlace=False)
@@ -4847,7 +4800,6 @@ class Test(unittest.TestCase):
 
     def testSliceByQuarterLengthsImported(self):
 
-        from music21 import corpus
         sSrc = corpus.parse('bwv66.6')
         s = copy.deepcopy(sSrc)
         for p in s.parts:
@@ -4921,7 +4873,6 @@ class Test(unittest.TestCase):
 
     def testSliceByGreatestDivisorImported(self):
 
-        from music21 import corpus
         sSrc = corpus.parse('bwv66.6')
         s = copy.deepcopy(sSrc)
         for p in s.parts:
@@ -4952,9 +4903,7 @@ class Test(unittest.TestCase):
         self.assertEqual(a, b)
 
     def testSliceAtOffsetsBuilt(self):
-
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         for p, ql in [('d2', 4)]:
             n = note.Note(p)
             n.quarterLength = ql
@@ -4969,7 +4918,7 @@ class Test(unittest.TestCase):
         s1 = s.sliceAtOffsets([0.5], inPlace=False)
         self.assertEqual([(e.offset, e.quarterLength) for e in s1], [(0.0, 0.5), (0.5, 3.5)])
 
-        s = stream.Stream()
+        s = Stream()
         for p, ql in [('a2', 1.5), ('a2', 1.5), ('a2', 1.5)]:
             n = note.Note(p)
             n.quarterLength = ql
@@ -4987,7 +4936,6 @@ class Test(unittest.TestCase):
                          [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
 
     def testSliceAtOffsetsImported(self):
-        from music21 import corpus
         sSrc = corpus.parse('bwv66.6')
 
         post = sSrc.parts[0].flat.sliceAtOffsets([0.25, 1.25, 3.25])
@@ -5011,8 +4959,7 @@ class Test(unittest.TestCase):
                          [0.0, 1.0, 1.5, 2.0, 2.125])
 
     def testSliceByBeatBuilt(self):
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         ts1 = meter.TimeSignature('3/4')
         s.insert(0, ts1)
         for p, ql in [('d2', 3)]:
@@ -5035,7 +4982,6 @@ class Test(unittest.TestCase):
                          [(0.0, 1.5), (1.5, 1.5)])
 
     def testSliceByBeatImported(self):
-        from music21 import corpus
         sSrc = corpus.parse('bwv66.6')
         post = sSrc.parts[0].sliceByBeat()
         self.assertEqual([e.offset for e in post.flat.notesAndRests],
@@ -5047,7 +4993,6 @@ class Test(unittest.TestCase):
         # post.show()
 
     def testChordifyImported(self):
-        from music21 import corpus
         s = corpus.parse('luca/gloria')
         # s.show()
         post = s.measures(0, 20, gatherSpanners=False)
@@ -5079,8 +5024,7 @@ class Test(unittest.TestCase):
 
     def testChordifyRests(self):
         # test that chordify does not choke on rests
-        from music21 import stream
-        p1 = stream.Part()
+        p1 = Part()
         for p, ql in [(None, 2), ('d2', 2), (None, 2), ('e3', 2), ('f3', 2)]:
             if p is None:
                 n = note.Rest()
@@ -5089,7 +5033,7 @@ class Test(unittest.TestCase):
             n.quarterLength = ql
             p1.append(n)
 
-        p2 = stream.Part()
+        p2 = Part()
         for p, ql in [(None, 2), ('c#3', 1), ('d#3', 1), (None, 2), ('e-5', 2), (None, 2)]:
             if p is None:
                 n = note.Rest()
@@ -5101,7 +5045,7 @@ class Test(unittest.TestCase):
         self.assertEqual([e.offset for e in p1], [0.0, 2.0, 4.0, 6.0, 8.0])
         self.assertEqual([e.offset for e in p2], [0.0, 2.0, 3.0, 4.0, 6.0, 8.0])
 
-        score = stream.Score()
+        score = Score()
         score.insert(0, p1)
         score.insert(0, p2)
         # parts retain their characteristics
@@ -5141,15 +5085,15 @@ class Test(unittest.TestCase):
             'Chord')[1].pitches), '(<music21.pitch.Pitch D2>, <music21.pitch.Pitch D#3>)')
 
     def testChordifyA(self):
-        from music21 import stream, expressions
-        p1 = stream.Part()
+        from music21 import expressions
+        p1 = Part()
         p1.insert(0, note.Note(quarterLength=12.0))
         p1.insert(0.25, expressions.TextExpression('test'))
         self.assertEqual(p1.highestTime, 12.0)
-        p2 = stream.Part()
+        p2 = Part()
         p2.repeatAppend(note.Note('g4'), 12)
 
-        s = stream.Score()
+        s = Score()
         s.insert(0, p1)
         s.insert(0, p2)
         post = s.chordify()
@@ -5157,15 +5101,15 @@ class Test(unittest.TestCase):
         self.assertEqual(str(post.getElementsByClass('Chord').first().pitches),
                          '(<music21.pitch.Pitch C4>, <music21.pitch.Pitch G4>)')
 
-        p1 = stream.Part()
+        p1 = Part()
         p1.insert(0, note.Note(quarterLength=12.0))
         p1.insert(0.25, expressions.TextExpression('test'))
         self.assertEqual(p1.highestTime, 12.0)
-        p2 = stream.Part()
+        p2 = Part()
         p2.repeatAppend(note.Note('g4', quarterLength=6.0), 2)
         # p.repeatAppend(note.Note('g4'), 12)
 
-        s = stream.Score()
+        s = Score()
         s.insert(0, p1)
         s.insert(0, p2)
         post = s.chordify()
@@ -5177,29 +5121,28 @@ class Test(unittest.TestCase):
         # s.show()
 
     def testChordifyB(self):
-        from music21 import stream
-        p1 = stream.Part()
-        m1a = stream.Measure()
+        p1 = Part()
+        m1a = Measure()
         m1a.timeSignature = meter.TimeSignature('4/4')
         m1a.insert(0, note.Note())
         m1a.padAsAnacrusis()
         self.assertEqual(m1a.paddingLeft, 3.0)
         # m1a.paddingLeft = 3.0  # a quarter pickup
-        m2a = stream.Measure()
+        m2a = Measure()
         m2a.repeatAppend(note.Note(), 4)
         p1.append([m1a, m2a])
 
-        p2 = stream.Part()
-        m1b = stream.Measure()
+        p2 = Part()
+        m1b = Measure()
         m1b.timeSignature = meter.TimeSignature('4/4')
         m1b.repeatAppend(note.Rest(), 1)
         m1b.padAsAnacrusis()
         self.assertEqual(m1b.paddingLeft, 3.0)
-        m2b = stream.Measure()
+        m2b = Measure()
         m2b.repeatAppend(note.Note('g4'), 4)
         p2.append([m1b, m2b])
 
-        s = stream.Score()
+        s = Score()
         s.insert(0, p1)
         s.insert(0, p2)
         # s.show()
@@ -5214,7 +5157,6 @@ class Test(unittest.TestCase):
         '''
         Chordifies with triplets (floating point errors)
         '''
-        from music21 import corpus
         s = corpus.parse('schoenberg/opus19/movement6')
         # s.show('text')
         m1 = s.parts.first().getElementsByClass('Measure').first()
@@ -5240,13 +5182,12 @@ class Test(unittest.TestCase):
         self.assertEqual(len(post.flat.getElementsByClass('Rest')), 4)
 
     def testChordifyD(self):
-        from music21 import stream
         # test on a Stream of Streams.
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.repeatAppend(note.Note(quarterLength=3), 4)
-        s2 = stream.Stream()
+        s2 = Stream()
         s2.repeatAppend(note.Note('g4', quarterLength=2), 6)
-        s3 = stream.Stream()
+        s3 = Stream()
         s3.insert(0, s1)
         s3.insert(0, s2)
 
@@ -5254,12 +5195,11 @@ class Test(unittest.TestCase):
         self.assertEqual(len(post.getElementsByClass('Chord')), 8)
 
     def testChordifyE(self):
-        from music21 import stream
-        s1 = stream.Stream()
-        m1 = stream.Measure()
-        v1 = stream.Voice()
+        s1 = Stream()
+        m1 = Measure()
+        v1 = Voice()
         v1.repeatAppend(note.Note('g4', quarterLength=1.5), 3)
-        v2 = stream.Voice()
+        v2 = Voice()
         v2.repeatAppend(note.Note(quarterLength=1), 6)
         m1.insert(0, v1)
         m1.insert(0, v2)
@@ -5273,7 +5213,6 @@ class Test(unittest.TestCase):
 
     # noinspection SpellCheckingInspection
     def testOpusSearch(self):
-        from music21 import corpus
         import re
         o = corpus.parse('essenFolksong/erk5')
         s = o.getScoreByTitle('blauen')
@@ -5319,7 +5258,6 @@ class Test(unittest.TestCase):
         self.assertEqual(inner.activeSite, outer)
 
     def testGetElementsByContextStream(self):
-        from music21 import corpus
 
         s = corpus.parse('bwv66.6')
         for p in s.parts:
@@ -5422,24 +5360,22 @@ class Test(unittest.TestCase):
     def testVoicesB(self):
 
         # make sure strip ties works
-        from music21 import stream
-
-        v1 = stream.Voice()
+        v1 = Voice()
         n1 = note.Note('c5')
         n1.quarterLength = 0.5
         v1.repeatAppend(n1, 27)
 
-        v2 = stream.Voice()
+        v2 = Voice()
         n2 = note.Note('c4')
         n2.quarterLength = 3
         v2.repeatAppend(n2, 6)
 
-        v3 = stream.Voice()
+        v3 = Voice()
         n3 = note.Note('c3')
         n3.quarterLength = 8
         v3.repeatAppend(n3, 4)
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, v1)
         s.insert(0, v2)
         s.insert(0, v3)
@@ -5455,18 +5391,17 @@ class Test(unittest.TestCase):
         # s.show()
 
     def testVoicesC(self):
-        from music21 import stream
-        v1 = stream.Voice()
+        v1 = Voice()
         n1 = note.Note('c5')
         n1.quarterLength = 0.25
         v1.repeatInsert(n1, [2, 4.5, 7.25, 11.75])
 
-        v2 = stream.Voice()
+        v2 = Voice()
         n2 = note.Note('c4')
         n2.quarterLength = 0.25
         v2.repeatInsert(n2, [0.25, 3.75, 5.5, 13.75])
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, v1)
         s.insert(0, v2)
 
@@ -5486,7 +5421,6 @@ class Test(unittest.TestCase):
         # sPost.show()
 
     def testPartsToVoicesA(self):
-        from music21 import corpus
         s0 = corpus.parse('bwv66.6')
         # s.show()
         s1 = s0.partsToVoices(2)
@@ -5545,7 +5479,6 @@ class Test(unittest.TestCase):
         # p1.show()
 
     def testPartsToVoicesB(self):
-        from music21 import corpus
         # this work has five parts: results in e parts
         s0 = corpus.parse('corelli/opus3no1/1grave')
         self.assertEqual(len(s0.parts), 3)
@@ -5607,7 +5540,6 @@ class Test(unittest.TestCase):
 
     def testVoicesToPartsA(self):
 
-        from music21 import corpus
         s0 = corpus.parse('bwv66.6')
         # s.show()
         s1 = s0.partsToVoices(2)  # produce two parts each with two voices
@@ -5701,10 +5633,9 @@ class Test(unittest.TestCase):
             self.assertIsNotNone(part.getElementsByClass("Measure")[1].rightBarline)
 
     def testMergeElements(self):
-        from music21 import stream
-        s1 = stream.Stream()
-        s2 = stream.Stream()
-        s3 = stream.Stream()
+        s1 = Stream()
+        s2 = Stream()
+        s3 = Stream()
 
         n1 = note.Note('f#')
         n2 = note.Note('g')
@@ -5723,14 +5654,14 @@ class Test(unittest.TestCase):
         self.assertEqual(len(s3), 2)
 
     def testDeepcopySpanners(self):
-        from music21 import spanner, stream
+        from music21 import spanner
         n1 = note.Note()
         n2 = note.Note('a4')
         n3 = note.Note('g#4')
         n3.quarterLength = 0.25
 
         su1 = spanner.Slur(n1, n2)
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.append(n1)
         s1.repeatAppend(n3, 4)
         s1.append(n2)
@@ -5760,7 +5691,7 @@ class Test(unittest.TestCase):
         # s2.show()
 
     def testAddSlurByMelisma(self):
-        from music21 import corpus, spanner
+        from music21 import spanner
         s = corpus.parse('luca/gloria')
         ex = s.parts[0]
         nStart = None
@@ -5808,15 +5739,13 @@ class Test(unittest.TestCase):
             # environLocal.printDebug(['melisma beat:', beatStr.ljust(6), 'average duration:', avg])
 
     def testTwoZeroOffset(self):
-        from music21 import stream
-        p = stream.Part()
+        p = Part()
         # p.append(instrument.Voice())
         p.append(note.Note('D#4'))
         # environLocal.printDebug([p.offsetMap()])
 
     def testStripTiesBuiltB(self):
-        from music21 import stream
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.append(meter.TimeSignature('4/4'))
         s1.append(note.Note(type='quarter'))
         s1.append(note.Note(type='half'))
@@ -5860,7 +5789,6 @@ class Test(unittest.TestCase):
         # s3.show()
 
     def testStripTiesImportedB(self):
-        from music21 import corpus
 
         # this file was imported by sibelius and does not have completed ties
         sMonte = corpus.parse('monteverdi/madrigal.4.2.xml')
@@ -5886,14 +5814,13 @@ class Test(unittest.TestCase):
                          [0.0, 0.5, 1.0, 1.5, 2.0, 3.0])
 
     def testDerivationA(self):
-        from music21 import stream, corpus
 
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.repeatAppend(note.Note(), 10)
         s1.repeatAppend(chord.Chord(), 10)
 
         # for testing against
-        s2 = stream.Stream()
+        s2 = Stream()
 
         s3 = s1.getElementsByClass('GeneralNote').stream()
         self.assertEqual(len(s3), 20)
@@ -5956,8 +5883,7 @@ class Test(unittest.TestCase):
         self.assertIs(p1.getElementsByClass('Measure')[3].activeSite, p1)
 
     def testDerivationB(self):
-        from music21 import stream
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.repeatAppend(note.Note(), 10)
         s1Flat = s1.flat
         self.assertIs(s1Flat.derivation.origin, s1)
@@ -5971,7 +5897,6 @@ class Test(unittest.TestCase):
         self.assertIs(s2._derivation.client, s2)
 
     def testDerivationC(self):
-        from music21 import corpus
         s = corpus.parse('bach/bwv66.6')
         p1 = s.parts['Soprano']
         pMeasures = p1.measures(3, 10)
@@ -5981,8 +5906,8 @@ class Test(unittest.TestCase):
                          [pMeasuresFlat, pMeasures, p1])
 
     def testDerivationMethodA(self):
-        from music21 import stream, converter
-        s1 = stream.Stream()
+        from music21 import converter
+        s1 = Stream()
         s1.repeatAppend(note.Note(), 10)
         s1Flat = s1.flat
         self.assertIs(s1Flat.derivation.origin, s1)
@@ -5998,7 +5923,6 @@ class Test(unittest.TestCase):
         self.assertEqual(s1m1.derivation.origin, None)
 
     def testContainerHierarchyA(self):
-        from music21 import corpus
         s = corpus.parse('bach/bwv66.6')
         # the part is not derived from anything yet
         self.assertEqual([str(e.__class__) for e in s[1][2][3].containerHierarchy()],
@@ -6015,8 +5939,7 @@ class Test(unittest.TestCase):
         # self.assertEqual([str(e.__class__) for e in s.parts[0].containerHierarchy()], [])
 
     def testMakeMeasuresTimeSignatures(self):
-        from music21 import stream
-        sSrc = stream.Stream()
+        sSrc = Stream()
         sSrc.append(note.Note('C4', type='quarter'))
         sSrc.append(note.Note('D4', type='quarter'))
         sSrc.append(note.Note('E4', type='quarter'))
@@ -6043,8 +5966,7 @@ class Test(unittest.TestCase):
 
     def testDeepcopyActiveSite(self):
         # test that active sites make sense after deepcopying
-        from music21 import stream, corpus
-        s = stream.Stream()
+        s = Stream()
         n = note.Note()
         s.append(n)
         self.assertEqual(id(n.activeSite), id(s))
@@ -6054,8 +5976,8 @@ class Test(unittest.TestCase):
         n1 = s1[0]
         self.assertEqual(id(n1.activeSite), id(s1))
 
-        s = stream.Stream()
-        m = stream.Measure()
+        s = Stream()
+        m = Measure()
         n = note.Note()
         m.append(n)
         s.append(m)
@@ -6088,7 +6010,6 @@ class Test(unittest.TestCase):
         self.assertEqual(id(p1.activeSite), id(s1))
 
     def testRecurseA(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         # default
         rElements = list(s.recurse(includeSelf=True))  # NOTE: list(s.recurse())
@@ -6142,7 +6063,6 @@ class Test(unittest.TestCase):
 
 
     def testRecurseB(self):
-        from music21 import corpus
 
         s = corpus.parse('madrigal.5.8.rntxt')
         self.assertEqual(len(s.flat.getElementsByClass('KeySignature')), 1)
@@ -6151,7 +6071,6 @@ class Test(unittest.TestCase):
         self.assertEqual(len(s.flat.getElementsByClass('KeySignature')), 0)
 
     def testTransposeScore(self):
-        from music21 import corpus
 
         s = corpus.parse('bwv66.6')
         p1 = s.parts[0]
@@ -6179,7 +6098,6 @@ class Test(unittest.TestCase):
         # b= a.flat.extendDuration(dynamics.Dynamic)
 
     def testSpannerTransferA(self):
-        from music21 import corpus
         # test getting spanners after .measures extraction
         s = corpus.parse('corelli/opus3no1/1grave')
         post = s.parts[0].measures(5, 10)
@@ -6193,7 +6111,6 @@ class Test(unittest.TestCase):
         # TODO: compare ids of new measures
 
     def testMeasureGrouping(self):
-        from music21 import corpus
 
         def parseMeasures(piece):
             # The measures of the piece, for a unique extraction
@@ -6221,8 +6138,7 @@ class Test(unittest.TestCase):
         parseMeasures(bach)
 
     def testMakeNotationByMeasuresA(self):
-        from music21 import stream
-        m = stream.Measure()
+        m = Measure()
         m.repeatAppend(note.Note('c#', quarterLength=0.5), 4)
         m.repeatAppend(note.Note('c', quarterLength=1 / 3), 6)
         # calls makeAccidentals, makeBeams, makeTuplets
@@ -6244,8 +6160,7 @@ class Test(unittest.TestCase):
         self.assertGreater(raw.find('<beam number="1">begin</beam>'), 0, raw)
 
     def testMakeNotationByMeasuresB(self):
-        from music21 import stream
-        m = stream.Measure()
+        m = Measure()
         m.repeatAppend(note.Note('c#', quarterLength=0.5), 4)
         m.repeatAppend(note.Note('c', quarterLength=1 / 3), 6)
         GEX = m21ToXml.GeneralObjectExporter()
@@ -6255,8 +6170,7 @@ class Test(unittest.TestCase):
             '<tuplet bracket="yes" number="1" placement="above" type="start"') > 0, raw)
 
     def testHaveAccidentalsBeenMadeA(self):
-        from music21 import stream
-        m = stream.Measure()
+        m = Measure()
         m.append(note.Note('c#'))
         m.append(note.Note('c'))
         m.append(note.Note('c#'))
@@ -6267,12 +6181,11 @@ class Test(unittest.TestCase):
         self.assertTrue(m.haveAccidentalsBeenMade())
 
     def testHaveAccidentalsBeenMadeB(self):
-        from music21 import stream
-        m1 = stream.Measure()
+        m1 = Measure()
         m1.repeatAppend(note.Note('c#'), 4)
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.repeatAppend(note.Note('c'), 4)
-        p = stream.Part()
+        p = Part()
         p.append([m1, m2])
         # p.show()
         # test result of xml output to make sure a natural has been added
@@ -6292,26 +6205,24 @@ class Test(unittest.TestCase):
         self.assertTrue(post.haveAccidentalsBeenMade())
 
     def testHaveBeamsBeenMadeA(self):
-        from music21 import stream
-        m1 = stream.Measure()
+        m1 = Measure()
         m1.timeSignature = meter.TimeSignature('4/4')
         m1.repeatAppend(note.Note('c#', quarterLength=0.5), 8)
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.repeatAppend(note.Note('c', quarterLength=0.5), 8)
-        p = stream.Part()
+        p = Part()
         p.append([m1, m2])
         self.assertFalse(p.streamStatus.beams)
         p.makeBeams(inPlace=True)
         self.assertTrue(p.streamStatus.beams)
 
     def testHaveBeamsBeenMadeB(self):
-        from music21 import stream
-        m1 = stream.Measure()
+        m1 = Measure()
         m1.timeSignature = meter.TimeSignature('4/4')
         m1.repeatAppend(note.Note('c#', quarterLength=0.5), 8)
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.repeatAppend(note.Note('c', quarterLength=0.5), 8)
-        p = stream.Part()
+        p = Part()
         p.append([m1, m2])
         self.assertFalse(p.streamStatus.beams)
         GEX = m21ToXml.GeneralObjectExporter()
@@ -6322,7 +6233,6 @@ class Test(unittest.TestCase):
         self.assertGreater(raw.find('<beam number="1">end</beam>'), 0)
 
     def testFlatCachingA(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         flat1 = s.flat
         flat2 = s.flat
@@ -6332,7 +6242,6 @@ class Test(unittest.TestCase):
         self.assertNotEqual(id(flat1), s.flat)
 
     def testFlatCachingB(self):
-        from music21 import corpus
         sSrc = corpus.parse('bach/bwv13.6.xml')
         sPart = sSrc.getElementById('Alto')
         ts = meter.TimeSignature('6/8')
@@ -6356,7 +6265,6 @@ class Test(unittest.TestCase):
                                   '2 1/3', '2 2/3', '1', '1 2/3', '2', '2 1/3'])
 
     def testFlatCachingC(self):
-        from music21 import corpus, stream
         qj = corpus.parse('ciconia/quod_jactatur').parts.first()
         unused_idFlat1 = id(qj.flat)
         # environLocal.printDebug(['idFlat1', idFlat1])
@@ -6367,7 +6275,7 @@ class Test(unittest.TestCase):
         unused_idFlat2 = id(qj.flat)
         # environLocal.printDebug(['idFlat2', idFlat2])
 
-        unused_m1 = qj.getElementsByClass(stream.Measure)[1]
+        unused_m1 = qj.getElementsByClass(Measure)[1]
         # m1.show('t')
         # m.insert(0, key.KeySignature(5))
         qj[1].insert(0, key.KeySignature(5))
@@ -6386,8 +6294,7 @@ class Test(unittest.TestCase):
         doctests sufficiently search invertDiatonic for complex cases,
         but not simple ones.
         '''
-        from music21 import stream
-        m = stream.Measure()
+        m = Measure()
         m.insert(0, note.Note('G4'))
         m2 = m.invertDiatonic()
         self.assertEqual(m2.recurse().notes[0].nameWithOctave, 'F3')
@@ -6401,7 +6308,6 @@ class Test(unittest.TestCase):
 
     def testSemiFlatCachingA(self):
 
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         ssf1 = s.semiFlat
         ssf2 = s.semiFlat
@@ -6417,21 +6323,10 @@ class Test(unittest.TestCase):
         self.assertEqual(beatStr, '3')
         # environLocal.printDebug(['beatStr', beatStr])
 
-#     def testDeepCopyLocations(self):
-#         from music21 import stream, note
-#         s1 = stream.Stream()
-#         n1 = note.Note()
-#         s1.append(n1)
-#         print([id(x) for x in n1.sites.get()])
-#         s2 = copy.deepcopy(s1)
-#         # pint s2[0].getSites()
-#         print([id(x) for x in s2[0].sites.get()])
-
     def testFlattenUnnecessaryVoicesA(self):
-        from music21 import stream
-        s = stream.Stream()
-        v1 = stream.Voice()
-        v2 = stream.Voice()
+        s = Stream()
+        v1 = Voice()
+        v2 = Voice()
         s.insert(0, v1)
         s.insert(0, v2)
 
@@ -6441,9 +6336,9 @@ class Test(unittest.TestCase):
         self.assertEqual(len(s.voices), 0)
 
         # next case: one voice empty, other with notes
-        s = stream.Stream()
-        v1 = stream.Voice()
-        v2 = stream.Voice()
+        s = Stream()
+        v1 = Voice()
+        v2 = Voice()
         n1 = note.Note()
         n2 = note.Note()
         v1.insert(10, n1)
@@ -6461,9 +6356,9 @@ class Test(unittest.TestCase):
         self.assertEqual(n2.getOffsetBySite(s), 70)
 
         # last case: two voices with notes
-        s = stream.Stream()
-        v1 = stream.Voice()
-        v2 = stream.Voice()
+        s = Stream()
+        v1 = Voice()
+        v2 = Voice()
         n1 = note.Note()
         n2 = note.Note()
         n3 = note.Note()
@@ -6484,8 +6379,7 @@ class Test(unittest.TestCase):
         self.assertEqual(len(s.notes), 3)
 
     def testGetElementBeforeOffsetA(self):
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         n1 = note.Note()
         n2 = note.Note()
         n3 = note.Note()
@@ -6504,8 +6398,7 @@ class Test(unittest.TestCase):
         self.assertEqual(s.getElementBeforeOffset(0.3, ['GeneralNote']), n1)
 
     def testGetElementBeforeOffsetB(self):
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         # fill with clefs to test class matching
         n1 = note.Note()
         n2 = note.Note()
@@ -6526,12 +6419,10 @@ class Test(unittest.TestCase):
         self.assertEqual(s.getElementBeforeOffset(0.3, ['Note']), n1)
 
     def testFinalBarlinePropertyA(self):
-        from music21 import stream
-
-        s = stream.Stream()
-        m1 = stream.Measure()
+        s = Stream()
+        m1 = Measure()
         m1.repeatAppend(note.Note(quarterLength=2.0), 2)
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.repeatAppend(note.Note(quarterLength=2.0), 2)
         s.append([m1, m2])
 
@@ -6550,7 +6441,6 @@ class Test(unittest.TestCase):
         # s.show()
 
     def testFinalBarlinePropertyB(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         sop = s.parts[0]
         self.assertEqual(str(sop.finalBarline), '<music21.bar.Barline type=final>')
@@ -6570,24 +6460,22 @@ class Test(unittest.TestCase):
                          + '<music21.bar.Barline type=final>, <music21.bar.Barline type=none>]')
 
     def testSetElementsFromOtherStreamWithEndElements(self):
-        from music21 import stream
         b = bar.Barline('double')
 
-        s = stream.Stream()
+        s = Stream()
         s.storeAtEnd(b)
 
-        c = stream.Stream()
+        c = Stream()
         c.elements = s
         self.assertIn(b, s)
 
     def testStreamElementsComparison(self):
-        from music21 import stream
-        s1 = stream.Stream()
+        s1 = Stream()
         s1.repeatAppend(note.Note(), 7)
         n1 = note.Note()
         s1.append(n1)
 
-        s2 = stream.Stream()
+        s2 = Stream()
         s2.elements = s1
         match = []
         for e in s2.elements:
@@ -6596,9 +6484,9 @@ class Test(unittest.TestCase):
         # have the same object in each stream
         self.assertEqual(id(s2[-1]), id(s1[-1]))
 
-        s3 = stream.Stream()
+        s3 = Stream()
 
-        s4 = stream.Stream()
+        s4 = Stream()
         s4.insert(25, n1)  # active site is now changed
 
         s3.elements = s1.elements
@@ -6624,7 +6512,7 @@ class Test(unittest.TestCase):
             match.append(e.getOffsetBySite(s3))
         self.assertEqual(match, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0])
 
-        s5 = stream.Stream()
+        s5 = Stream()
         s5.elements = s1
         match = []
         for e in s5.elements:
@@ -6632,33 +6520,33 @@ class Test(unittest.TestCase):
         self.assertEqual(match, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0])
 
     def testSecondsPropertyA(self):
-        from music21 import stream, tempo
+        from music21 import tempo
 
         # simple case of one tempo
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, tempo.MetronomeMark(number=60))
         s.repeatAppend(note.Note(), 60)
         self.assertEqual(s.seconds, 60.0)
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, tempo.MetronomeMark(number=90))
         s.repeatAppend(note.Note(), 60)
         self.assertEqual(s.seconds, 40.0)
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, tempo.MetronomeMark(number=120))
         s.repeatAppend(note.Note(), 60)
         self.assertEqual(s.seconds, 30.0)
 
         # changing tempo mid-stream
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, tempo.MetronomeMark(number=60))
         s.repeatAppend(note.Note(), 60)
         s.insert(30, tempo.MetronomeMark(number=120))
         # 30 notes at 60, 30 notes at 120
         self.assertEqual(s.seconds, 30.0 + 15.0)
 
-        s = stream.Stream()
+        s = Stream()
         s.insert(0, tempo.MetronomeMark(number=60))
         s.repeatAppend(note.Note(), 60)
         s.insert(15, tempo.MetronomeMark(number=120))
@@ -6669,8 +6557,7 @@ class Test(unittest.TestCase):
         self.assertEqual(s.seconds, 15.0 + 7.5 + 3.75 + 1.875)
 
     def testSecondsPropertyB(self):
-
-        from music21 import corpus, tempo
+        from music21 import tempo
 
         s = corpus.parse('bwv66.6')
         sFlat = s.flat
@@ -6688,22 +6575,22 @@ class Test(unittest.TestCase):
         self.assertAlmostEqual(sFlat.seconds, 10.38461538)
 
     def testSecondsPropertyC(self):
-        from music21 import stream, tempo
+        from music21 import tempo
 
-        s = stream.Stream()
-        m1 = stream.Measure()
+        s = Stream()
+        m1 = Measure()
         m1.timeSignature = meter.TimeSignature('3/4')
         mm = tempo.MetronomeMark(number=60)
         m1.insert(0, mm)
         m1.insert(note.Note(quarterLength=3))
         s.append(m1)
 
-        m2 = stream.Measure()
+        m2 = Measure()
         m2.timeSignature = meter.TimeSignature('5/4')
         m2.insert(note.Note(quarterLength=5))
         s.append(m2)
 
-        m3 = stream.Measure()
+        m3 = Measure()
         m3.timeSignature = meter.TimeSignature('2/4')
         m3.insert(note.Note(quarterLength=2))
         s.append(m3)
@@ -6718,15 +6605,14 @@ class Test(unittest.TestCase):
 
     # TODO: New piece with Metronome Mark Boundaries
 #     def testMetronomeMarkBoundaries(self):
-#         from music21 import corpus
-#         s = corpus.parse('hwv56/movement2-09.md')
+# #         s = corpus.parse('hwv56/movement2-09.md')
 #         mmBoundaries = s.metronomeMarkBoundaries()
 #         self.assertEqual(str(mmBoundaries),
 #                '[(0.0, 20.0, <music21.tempo.MetronomeMark Largo e piano Quarter=46>)]')
 
     def testAccumulatedTimeA(self):
-        from music21 import stream, tempo
-        s = stream.Stream()
+        from music21 import tempo
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([0, tempo.MetronomeMark(number=60)])
         mmBoundaries = s.metronomeMarkBoundaries()
@@ -6735,7 +6621,7 @@ class Test(unittest.TestCase):
         self.assertEqual(s._accumulatedSeconds(mmBoundaries, 0, 8), 8.0)
 
         # changing in the middle of boundary
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([0, tempo.MetronomeMark(number=60),
                   4, tempo.MetronomeMark(number=120)])
@@ -6745,10 +6631,10 @@ class Test(unittest.TestCase):
         self.assertEqual(s._accumulatedSeconds(mmBoundaries, 0, 8), 6.0)
 
     def testAccumulatedTimeB(self):
-        from music21 import stream, tempo
+        from music21 import tempo
 
         # changing in the middle of boundary
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([0, tempo.MetronomeMark(number=60),
                   4, tempo.MetronomeMark(number=120),
@@ -6760,8 +6646,8 @@ class Test(unittest.TestCase):
         self.assertEqual(s._accumulatedSeconds(mmBoundaries, 0, 8), 5.5)
 
     def testSecondsMapA(self):
-        from music21 import stream, tempo
-        s = stream.Stream()
+        from music21 import tempo
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([0, tempo.MetronomeMark(number=90),
                   4, tempo.MetronomeMark(number=120),
@@ -6772,7 +6658,7 @@ class Test(unittest.TestCase):
                          + '(6.0, 8.0, <music21.tempo.MetronomeMark Quarter=240>)]')
 
         # not starting
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([4, tempo.MetronomeMark(number=120),
                   6, tempo.MetronomeMark(number=240)])
@@ -6782,13 +6668,13 @@ class Test(unittest.TestCase):
                          + '(6.0, 8.0, <music21.tempo.MetronomeMark Quarter=240>)]')
 
         # none
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         self.assertEqual(str(s.metronomeMarkBoundaries()),
                          '[(0.0, 8.0, <music21.tempo.MetronomeMark animato Quarter=120>)]')
 
         # ont mid stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([6, tempo.MetronomeMark(number=240)])
         self.assertEqual(str(s.metronomeMarkBoundaries()),
@@ -6796,16 +6682,16 @@ class Test(unittest.TestCase):
                          + '(6.0, 8.0, <music21.tempo.MetronomeMark Quarter=240>)]')
 
         # one start stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 8)
         s.insert([0, tempo.MetronomeMark(number=240)])
         self.assertEqual(str(s.metronomeMarkBoundaries()),
                          '[(0.0, 8.0, <music21.tempo.MetronomeMark Quarter=240>)]')
 
     def testSecondsMapB(self):
-        from music21 import stream, tempo
+        from music21 import tempo
         # one start stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 2)
         s.insert([0, tempo.MetronomeMark(number=60)])
 
@@ -6831,7 +6717,7 @@ class Test(unittest.TestCase):
                          + "'element': <music21.note.Note C>, "
                          + "'offsetSeconds': 1.0, 'endTimeSeconds': 2.0}]""")
 
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 2)
         s.insert([0, tempo.MetronomeMark(number=15)])
 
@@ -6857,7 +6743,7 @@ class Test(unittest.TestCase):
                          + "'element': <music21.note.Note C>, "
                          + "'offsetSeconds': 4.0, 'endTimeSeconds': 8.0}]""")
 
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note(), 2)
         s.insert([0, tempo.MetronomeMark(number=15),
                   1, tempo.MetronomeMark(number=60)])
@@ -6887,7 +6773,7 @@ class Test(unittest.TestCase):
                          + "'element': <music21.note.Note C>, "
                          + "'offsetSeconds': 4.0, 'endTimeSeconds': 5.0}]")
 
-        s = stream.Stream()
+        s = Stream()
         s.append(note.Note(quarterLength=2.0))
         s.insert([0, tempo.MetronomeMark(number=15),
                   1, tempo.MetronomeMark(number=60)])
@@ -6916,14 +6802,13 @@ class Test(unittest.TestCase):
                          + "'offsetSeconds': 4.0, 'endTimeSeconds': 4.0}]")
 
     def testPartDurationA(self):
-        from music21 import stream
         # s= corpus.parse('bach/bwv7.7')
-        p1 = stream.Part()
+        p1 = Part()
         p1.append(note.Note(quarterLength=72))
-        p2 = stream.Part()
+        p2 = Part()
         p2.append(note.Note(quarterLength=72))
 
-        sNew = stream.Score()
+        sNew = Score()
         sNew.append(p1)
         self.assertEqual(str(sNew.duration), '<music21.duration.Duration 72.0>')
         self.assertEqual(sNew.duration.quarterLength, 72.0)
@@ -6934,9 +6819,8 @@ class Test(unittest.TestCase):
         # sPost.show()
 
     def testPartDurationB(self):
-        from music21 import stream, corpus
         s = corpus.parse('bach/bwv66.6')
-        sNew = stream.Score()
+        sNew = Score()
         sNew.append(s.parts[0])
         self.assertEqual(str(s.parts[0].duration), '<music21.duration.Duration 36.0>')
         self.assertEqual(str(sNew.duration), '<music21.duration.Duration 36.0>')
@@ -6945,15 +6829,14 @@ class Test(unittest.TestCase):
         self.assertEqual(sNew.duration.quarterLength, 72.0)
 
     def testChordifyTagPartA(self):
-        from music21 import stream
-        p1 = stream.Part()
+        p1 = Part()
         p1.id = 'a'
         p1.repeatAppend(note.Note('g4', quarterLength=2), 6)
-        p2 = stream.Part()
+        p2 = Part()
         p2.repeatAppend(note.Note('c4', quarterLength=3), 4)
         p2.id = 'b'
 
-        s = stream.Score()
+        s = Score()
         s.insert(0, p1)
         s.insert(0, p2)
         post = s.chordify(addPartIdAsGroup=True, removeRedundantPitches=False)
@@ -6971,7 +6854,6 @@ class Test(unittest.TestCase):
         self.assertEqual(idB, ['C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'])
 
     def testChordifyTagPartB(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         idSoprano = []
         idAlto = []
@@ -7009,19 +6891,19 @@ class Test(unittest.TestCase):
         self.assertEqual(len(idSoprano), len(idAlto))
 
     def testTransposeByPitchA(self):
-        from music21 import stream, instrument
+        from music21 import instrument
 
         i1 = instrument.EnglishHorn()  # -p5
         i2 = instrument.Clarinet()  # -M2
 
-        p1 = stream.Part()
+        p1 = Part()
         p1.repeatAppend(note.Note('C4'), 4)
         p1.insert(0, i1)
         p1.insert(2, i2)
-        p2 = stream.Part()
+        p2 = Part()
         p2.repeatAppend(note.Note('C4'), 4)
         p2.insert(0, i2)
-        s = stream.Score()
+        s = Score()
         s.insert(0, p1)
         s.insert(0, p2)
 
@@ -7098,9 +6980,7 @@ class Test(unittest.TestCase):
                          ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5'])
 
     def testExtendTiesA(self):
-        from music21 import stream
-
-        s = stream.Stream()
+        s = Stream()
         s.append(note.Note('g4'))
         s.append(chord.Chord(['c3', 'g4', 'a5']))
         s.append(note.Note('a5'))
@@ -7125,7 +7005,6 @@ class Test(unittest.TestCase):
                           ])
 
     def testExtendTiesB(self):
-        from music21 import corpus
         self.maxDiff = None
 
         s = corpus.parse('bwv66.6')
@@ -7156,8 +7035,7 @@ class Test(unittest.TestCase):
         # sChords.show()
 
     def testInsertIntoNoteOrChordA(self):
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('d4'), 8)
         s.insertIntoNoteOrChord(3, note.Note('g4'))
         self.assertEqual([repr(e) for e in s],
@@ -7205,8 +7083,7 @@ class Test(unittest.TestCase):
         # s.show('text')
 
     def testInsertIntoNoteOrChordB(self):
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(chord.Chord(['c4', 'e4', 'g4']), 8)
 
         s.insertIntoNoteOrChord(5, note.Note('b4'))
@@ -7224,7 +7101,6 @@ class Test(unittest.TestCase):
                           '<music21.chord.Chord C4 E4 G4>'])
 
     def testSortingAfterInsertA(self):
-        from music21 import corpus
         import math
 
         s = corpus.parse('bwv66.6')
@@ -7272,28 +7148,25 @@ class Test(unittest.TestCase):
         <stem>up</stem>
       </note>
       <note>'''
-
         GEX = m21ToXml.GeneralObjectExporter()
         originalRaw = GEX.parse(p).decode('utf-8')
         match = match.replace(' ', '')
         match = match.replace('\n', '')
         raw = originalRaw.replace(' ', '')
         raw = raw.replace('\n', '')
-        self.assertEqual(raw.find(match) > 0, True, raw)
+        self.assertEqual(raw.find(match) > 0, True, originalRaw)
 
     def testInvertDiatonicA(self):
         # TODO: Check results
-        from music21 import corpus, stream
 
         qj = corpus.parse('ciconia/quod_jactatur').parts[0]
 
         k1 = qj.flat.getElementsByClass(key.KeySignature)[0]
         qj.flat.replace(k1, key.KeySignature(-3))
-        qj.getElementsByClass(stream.Measure)[1].insert(0, key.KeySignature(5))
+        qj.getElementsByClass(Measure)[1].insert(0, key.KeySignature(5))
         unused_qj2 = qj.invertDiatonic(note.Note('F4'), inPlace=False)
 
     def testMeasuresA(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         ex = s.parts[0].measures(3, 6)
 
@@ -7317,7 +7190,6 @@ class Test(unittest.TestCase):
         self.assertEqual(len(ex.flat.getElementsByClass('Rest')), 5)
 
     def testMeasuresB(self):
-        from music21 import corpus
         s = corpus.parse('luca/gloria')
         y = s.measures(50, 90)
 
@@ -7341,7 +7213,6 @@ class Test(unittest.TestCase):
         self.assertGreater(raw.find(match), 0)
 
     def testMeasuresC(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         ex = s.parts[0].measures(3, 6)
         for n in list(ex.recurse(classFilter=['Note'])):
@@ -7355,12 +7226,11 @@ class Test(unittest.TestCase):
         # ex.show()
 
     def testMeasuresSuffix(self):
-        from music21 import stream
-        p = stream.Part()
-        m1 = stream.Measure(number=1)
-        m2a = stream.Measure(number='2a')
-        m2b = stream.Measure(number='2b')
-        m3 = stream.Measure(number=3)
+        p = Part()
+        m1 = Measure(number=1)
+        m2a = Measure(number='2a')
+        m2b = Measure(number='2b')
+        m3 = Measure(number=3)
         p.append(m1)
         p.append(m2a)
         p.append(m2b)
@@ -7454,9 +7324,8 @@ class Test(unittest.TestCase):
         #    self.assertEqual(len(c), 2)
 
     def testChordifyG(self):
-        from music21 import stream
         # testing a problem in triplets in makeChords
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('G4', quarterLength=1 / 3), 6)
         s.insert(0, note.Note('C4', quarterLength=2))
         chords = s.chordify()
@@ -7465,7 +7334,7 @@ class Test(unittest.TestCase):
             self.assertEqual(len(c), 2)
 
         # try with small divisions
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('G4', quarterLength=1 / 6), 12)
         s.insert(0, note.Note('C4', quarterLength=2))
         chords = s.chordify()
@@ -7473,7 +7342,7 @@ class Test(unittest.TestCase):
         for c in chords.getElementsByClass('Chord'):
             self.assertEqual(len(c), 2)
 
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('G4', quarterLength=1 / 12), 24)
         s.insert(0, note.Note('C4', quarterLength=2))
         chords = s.chordify()
@@ -7481,7 +7350,7 @@ class Test(unittest.TestCase):
         for c in chords.getElementsByClass('Chord'):
             self.assertEqual(len(c), 2)
 
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('G4', quarterLength=1 / 24), 48)
         s.insert(0, note.Note('C4', quarterLength=2))
         chords = s.chordify()
@@ -7490,8 +7359,7 @@ class Test(unittest.TestCase):
             self.assertEqual(len(c), 2)
 
     def testMakeVoicesA(self):
-        from music21 import stream
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('d-4', quarterLength=1), 8)
         s.insert(0, note.Note('C4', quarterLength=8))
         s.makeVoices(inPlace=True)
@@ -7502,7 +7370,6 @@ class Test(unittest.TestCase):
         # s.show()
 
     def testMakeVoicesB(self):
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         # s.measures(6, 7).show()
         sMeasures = s.measures(6, 7)
@@ -7515,32 +7382,54 @@ class Test(unittest.TestCase):
         self.assertEqual(len(sFlatVoiced.voices), 4)
 
     def testSplitAtQuarterLengthA(self):
-        from music21 import stream
-        s = stream.Measure()
-        s.append(note.Note('a', quarterLength=1))
-        s.append(note.Note('b', quarterLength=2))
-        s.append(note.Note('c', quarterLength=1))
-
+        def getS():
+            ss = Measure()
+            ss.append(note.Note('a', quarterLength=1))
+            ss.append(note.Note('b', quarterLength=2))
+            ss.append(note.Note('c', quarterLength=1))
+            return ss
+
+        s = getS()
         l, r = s.splitAtQuarterLength(2, retainOrigin=True)
         # if retain origin is true, l is the original
-        self.assertEqual(l, s)
+        self.assertIs(l, s)
         self.assertEqual(l.highestTime, 2)
         self.assertEqual(len(l.notes), 2)
         self.assertEqual(r.highestTime, 2)
         self.assertEqual(len(r.notes), 2)
 
-        sPost = stream.Stream()
+        sPost = Stream()
         sPost.append(l)
         sPost.append(r)
 
+        s = getS()
+        l2, r2 = s.splitAtQuarterLength(2, retainOrigin=False)
+        self.assertIsNot(l2, s)
+        self.assertEqual(l2.highestTime, l.highestTime)
+        self.assertEqual(len(l2), len(l))
+        self.assertEqual(len(r2.notes), 2)
+
+        s = getS()
+        l3, r3 = s.splitAtQuarterLength(5)
+        self.assertEqual(len(l3.notes), 3)
+        self.assertEqual(len(r3), 0, r3.elements)
+
+        s = getS()
+        s.insert(0, meter.TimeSignature('2/2'))
+        l4, r4 = s.splitAtQuarterLength(5)
+        self.assertEqual(len(l4), 4)
+        self.assertEqual(len(r4), 1)
+        self.assertIsInstance(r4[0], meter.TimeSignature)
+        self.assertEqual(r4[0].ratioString, '2/2')
+
+
     def testSplitAtQuarterLengthB(self):
         '''Test if recursive calls work over voices in a Measure
         '''
-        from music21 import stream
-        m1 = stream.Measure()
-        v1 = stream.Voice()
+        m1 = Measure()
+        v1 = Voice()
         v1.repeatAppend(note.Note('g4', quarterLength=2), 3)
-        v2 = stream.Voice()
+        v2 = Voice()
         v2.repeatAppend(note.Note(quarterLength=6), 1)
         m1.insert(0, v1)
         m1.insert(0, v2)
@@ -7552,7 +7441,7 @@ class Test(unittest.TestCase):
         self.assertEqual(len(mRight.flat.notes), 3)
         self.assertEqual(len(mRight.voices), 2)
 
-        sPost = stream.Stream()
+        sPost = Stream()
         sPost.append(mLeft)
         sPost.append(mRight)
         # sPost.show()
@@ -7560,7 +7449,6 @@ class Test(unittest.TestCase):
     def testSplitAtQuarterLengthC(self):
         '''Test splitting a Score
         '''
-        from music21 import corpus
         s = corpus.parse('bwv66.6')
         sLeft, sRight = s.splitAtQuarterLength(6)
 
@@ -7583,9 +7471,9 @@ class Test(unittest.TestCase):
 
     def testGracesInStream(self):
         '''testing grace notes'''
-        from music21 import stream, dynamics
+        from music21 import dynamics
 
-        s = stream.Measure()
+        s = Measure()
         s.append(note.Note('G3'))
         self.assertEqual(s.highestTime, 1.0)
         # shows up in the same position as the following note, not the grace
@@ -7628,9 +7516,9 @@ class Test(unittest.TestCase):
         self.assertEqual(match, ['G3', 'C#4', 'C4', 'D#4', 'A4'])
 
     def testGraceChords(self):
-        from music21 import stream
 
-        s = stream.Measure()
+
+        s = Measure()
         s.append(chord.Chord(['G3', 'd4']))
 
         gc1 = chord.Chord(['d#4', 'a#4'], quarterLength=0.5)
@@ -7653,8 +7541,8 @@ class Test(unittest.TestCase):
 
     def testScoreShowA(self):
         # this checks the specific handling of Score.makeNotation()
-        from music21 import stream
-        s = stream.Stream()
+
+        s = Stream()
         s.append(key.Key('G'))
         GEX = m21ToXml.GeneralObjectExporter()
         raw = GEX.parse(s).decode('utf-8')
@@ -7662,8 +7550,8 @@ class Test(unittest.TestCase):
         self.assertGreater(raw.find('<fifths>1</fifths>'), 0, raw)
 
     def testGetVariantsA(self):
-        from music21 import stream, variant
-        s = stream.Stream()
+        from music21 import variant
+        s = Stream()
         v1 = variant.Variant()
         v2 = variant.Variant()
         s.append(v1)
@@ -7673,13 +7561,13 @@ class Test(unittest.TestCase):
     def testActivateVariantsA(self):
         '''This tests a single-measure variant
         '''
-        from music21 import stream, variant
-        s = stream.Stream()
+        from music21 import variant
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 12)
         s.makeMeasures(inPlace=True)
 
         v1 = variant.Variant()
-        m2Alt = stream.Measure()
+        m2Alt = Measure()
         m2Alt.repeatAppend(note.Note('G#4'), 4)
         v1.append(m2Alt)  # embed a complete Measure in v1
 
@@ -7705,19 +7593,19 @@ class Test(unittest.TestCase):
     def testActivateVariantsB(self):
         '''This tests two variants with different groups, each a single measure
         '''
-        from music21 import stream, variant
-        s = stream.Stream()
+        from music21 import variant
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 12)
         s.makeMeasures(inPlace=True)
 
         v1 = variant.Variant()
-        m2Alt = stream.Measure()
+        m2Alt = Measure()
         m2Alt.repeatAppend(note.Note('a#4'), 4)
         v1.append(m2Alt)  # embed a complete Measure in v1
         v1.groups.append('m2-a')
 
         v2 = variant.Variant()
-        m2Alt = stream.Measure()
+        m2Alt = Measure()
         m2Alt.repeatAppend(note.Note('b-4'), 4)
         v2.append(m2Alt)  # embed a complete Measure in v1
         v2.groups.append('m2-b')
@@ -7755,16 +7643,16 @@ class Test(unittest.TestCase):
     def testActivateVariantsC(self):
         '''This tests a two-measure variant
         '''
-        from music21 import stream, variant
-        s = stream.Stream()
+        from music21 import variant
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 12)
         s.makeMeasures(inPlace=True)
 
         v1 = variant.Variant()
-        m2Alt = stream.Measure()
+        m2Alt = Measure()
         m2Alt.repeatAppend(note.Note('G#4'), 4)
         v1.append(m2Alt)  # embed a complete Measure in v1
-        m3Alt = stream.Measure()
+        m3Alt = Measure()
         m3Alt.repeatAppend(note.Note('A#4'), 4)
         v1.append(m3Alt)  # embed a complete Measure in v1
 
@@ -7792,8 +7680,8 @@ class Test(unittest.TestCase):
         '''This tests a note-level variant
         '''
 
-        from music21 import stream, variant
-        s = stream.Stream()
+        from music21 import variant
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 12)
 
         v = variant.Variant()
@@ -7828,8 +7716,8 @@ class Test(unittest.TestCase):
     def testActivateVariantsE(self):
         '''This tests a note-level variant with miss-matched rhythms
         '''
-        from music21 import stream, variant
-        s = stream.Stream()
+        from music21 import variant
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 12)
 
         v = variant.Variant()
@@ -7860,9 +7748,9 @@ class Test(unittest.TestCase):
     def testActivateVariantsBySpanA(self):
         # this tests replacing 1 note with a 3-note variant
 
-        from music21 import stream, variant, dynamics
+        from music21 import variant, dynamics
 
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 12)
 
         v = variant.Variant()
@@ -7899,14 +7787,14 @@ class Test(unittest.TestCase):
     def testActivateVariantsBySpanB(self):
         # this tests replacing 2 measures by a longer single measure
 
-        from music21 import stream, variant
+        from music21 import variant
 
-        s = stream.Stream()
+        s = Stream()
         s.repeatAppend(note.Note('d2'), 16)
         s.makeMeasures(inPlace=True)
 
         v1 = variant.Variant()
-        m2Alt = stream.Measure()
+        m2Alt = Measure()
         m2Alt.repeatAppend(note.Note('a#4'), 8)
         m2Alt.timeSignature = meter.TimeSignature('8/4')
         v1.append(m2Alt)  # embed a complete Measure in v1
@@ -7938,7 +7826,6 @@ class Test(unittest.TestCase):
         # s.show()
 
     def testTemplateAll(self):
-        from music21 import corpus
         b = corpus.parse('bwv66.6')
         bass = b.parts[3]
         bassEmpty = bass.template(fillWithRests=False, removeClasses=True)
@@ -7998,7 +7885,6 @@ class Test(unittest.TestCase):
     #     test that after chordification, only
     #     the specific time point with a fermata has a fermata.
     #     '''
-    #     from music21 import corpus
     #     schoenberg = corpus.parse('schoenberg/opus19', 6)
     #     excerpt = schoenberg.measures(10, 10)
     #     chordBefore = excerpt.parts[0].getElementsByClass('Measure')[0].notes[0]