tox/travis stuff. making testing more uniform.
This commit is contained in:
parent
c2b03afe55
commit
ca66e74099
6 changed files with 35 additions and 89 deletions
|
@ -10,7 +10,8 @@ def mock_network():
|
|||
_get_ws_auth=mock.Mock(return_value=("", "", ""))
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize('unicode_artist', [u'\xe9lafdasfdsafdsa', u'éééééééé'])
|
||||
|
||||
@pytest.mark.parametrize('unicode_artist', [u'\xe9lafdasfdsafdsa', u'ééééééé])
|
||||
def test_get_cache_key(unicode_artist):
|
||||
request = pylast._Request(mock_network(), 'some_method',
|
||||
params={'artist': unicode_artist})
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
from random import choice
|
||||
import sys
|
||||
|
@ -1909,54 +1908,4 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertEqual(str(tracks[0].track.artist), "Johnny Cash")
|
||||
self.assertEqual(str(tracks[0].track.title), "Ring of Fire")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Integration (not unit) tests for pylast.py",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument(
|
||||
'-1', '--single',
|
||||
help="Run a single test")
|
||||
parser.add_argument(
|
||||
'-r', '--repeat',
|
||||
help="Repeat a single test (100 times) until failure")
|
||||
parser.add_argument(
|
||||
'-m', '--matching',
|
||||
help="Run tests with this in the name")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.single:
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
suite.addTest(TestPyLast(args.single))
|
||||
unittest.TextTestRunner().run(suite)
|
||||
|
||||
elif args.repeat:
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
suite.addTest(TestPyLast(args.repeat))
|
||||
for i in range(100):
|
||||
print("Attempt " + str(i+1))
|
||||
result = unittest.TextTestRunner().run(suite)
|
||||
problems = len(result.errors) + len(result.failures)
|
||||
if problems:
|
||||
break
|
||||
|
||||
elif args.matching:
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
import inspect
|
||||
methods = inspect.getmembers(TestPyLast, predicate=inspect.ismethod)
|
||||
|
||||
tests = []
|
||||
for method, _ in methods:
|
||||
if method.startswith("test_") and args.matching in method:
|
||||
print(method)
|
||||
suite.addTest(TestPyLast(method))
|
||||
|
||||
unittest.TextTestRunner().run(suite)
|
||||
|
||||
else:
|
||||
unittest.main(failfast=True)
|
||||
|
||||
# End of file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue