Skip to content

Commit 3788a4b

Browse files
committed
Reorganize test packages and remove custom runners
* Custom runners are unneeded with the builtin "unittest discovery" command. * Reorganize test packages and avoid conflicts with the builtin `unittest` module. * Remove unneeded path and suite boilerplate from tests.
1 parent 4369741 commit 3788a4b

34 files changed

Lines changed: 55 additions & 302 deletions

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ PATH := $(project_dir)/venv/bin:$(PATH)
44
all:
55

66
format:
7-
python -m black mingus mingus_examples unittest
7+
python -m black mingus mingus_examples tests
88

99
dev:
1010
pip install -e '.[fft,fluidsynth]' -r requirements-dev.in
1111

1212
install:
1313
pip install .
1414

15-
test:
16-
(cd unittest; python run_tests.py)
15+
test: test-unit
16+
17+
test-unit:
18+
python -m unittest discover tests.unit
1719

1820
test-fluidsynth:
19-
(cd unittest; python run_fluidsynth_tests.py)
21+
python -m unittest tests.integration.test_fluidsynth
2022

2123
test-lilypond:
22-
(cd unittest; python run_lilypond_tests.py)
24+
python -m unittest tests.integration.test_lilypond
2325

2426
test-all: test test-fluidsynth test-lilypond
2527

@@ -47,6 +49,6 @@ release: clean build sign-build upload tag
4749

4850
.PHONY: format \
4951
dev install \
50-
test test-fluidsynth test-lilypond test-all \
52+
test test-unit test-fluidsynth test-lilypond test-all \
5153
clean build \
5254
upload tag release

tests/__init__.py

Whitespace-only changes.
File renamed without changes.

tests/integration/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class test_fluidsynth(unittest.TestCase):
2020
2121
Check the :py:mod:`mingus.midi.fluidsynth` module for tips on finding
2222
SoundFonts.
23+
24+
Remember: you need a running fluidsynth server process listening at port
25+
9800 to pass this test.
2326
"""
2427

2528
def setUp(self):
@@ -191,7 +194,3 @@ def test_composition(self):
191194
c + t
192195
c + t2
193196
self.assertTrue(fluidsynth.play_Composition(c))
194-
195-
196-
def suite():
197-
return unittest.TestLoader().loadTestsFromTestCase(test_fluidsynth)
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,3 @@ def test_to_png(self):
189189
)
190190
self.assertTrue(LilyPond.to_png(LilyPond.from_Bar(self.tbar), "pn2"))
191191
self.assertTrue(LilyPond.to_png(LilyPond.from_Bar(self.mbar), "pn3"))
192-
193-
194-
def suite():
195-
return unittest.TestLoader().loadTestsFromTestCase(test_LilyPond)

tests/unit/__init__.py

Whitespace-only changes.

tests/unit/containers/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import
23

3-
# -*- coding: utf-8 -*-
4-
import sys
4+
import unittest
55

6-
sys.path += ["../"]
7-
from mingus.core.keys import Key
86
from mingus.containers.bar import Bar
97
from mingus.containers.note import Note
108
from mingus.containers.note_container import NoteContainer
11-
from mingus.containers.mt_exceptions import MeterFormatError
12-
import unittest
9+
from mingus.core.keys import Key
1310

1411

1512
class test_Bar(unittest.TestCase):
@@ -121,7 +118,3 @@ def test_determine_progression(self):
121118
b + ["C", "E", "G"]
122119
b + ["F", "A", "C"]
123120
self.assertEqual([[0.0, ["I"]], [0.25, ["IV"]]], b.determine_progression(True))
124-
125-
126-
def suite():
127-
return unittest.TestLoader().loadTestsFromTestCase(test_Bar)
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import
23

3-
# -*- coding: utf-8 -*-
4-
import sys
4+
import unittest
55

6-
sys.path += ["../"]
6+
# noinspection PyUnresolvedReferences
77
from mingus.containers.composition import Composition
8-
import unittest
98

109

1110
class test_Composition(unittest.TestCase):
1211
def setUp(self):
1312
pass
14-
15-
16-
def suite():
17-
return unittest.TestLoader().loadTestsFromTestCase(test_Composition)

0 commit comments

Comments
 (0)