pytest is used for unit testing. The tests are found in mido/test_*.py.

If possible please run tests in both Python 2 and Python 3 before you commit code:

python2 -m pytest && python3 -m pytest

You can also set up a commit hook:

echo "python2 -m pytest && python3 -m pytest" >.git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

This will run tests when you commit and cancel the commit if any tests fail.

Testing MIDI file support

Test Files

The Lakh MIDI Dataset is a great resouce for testing the MIDI file parser.

Publishing (Release Checklist)

I am currently the only one with access to publishing on PyPI and readthedocs. This will hopefully change in the future.

First Time: Register With PyPI

./ register


rm -rf docs/_build && ./ docs
pytest2 && pytest3
check-manifest -v

(pip3 install check-manifest)

You can also test that the package installs by installing it in a virtualenv with pip and easy_install (Python 2 and 3) and importing it. This is a bit tedious. Perhaps there is a good way to automate it.

Bump Version

X.Y.Z is the version, for example 1.1.18 or 1.2.0.

  • update version and date in docs/changes.rst
  • update version in mido/
  • git commit -a -c “Bumped version to X.Y.Z.”


git tag X.Y.Z
git push
git push --tags

Update the stable branch (if this is a stable release):

git checkout stable
git pull . master
git push
git checkout master


Publish in PyPI:

python publish
python bdist_wheel upload

Last thing:

Update readthedocs