From: yomguy Date: Wed, 19 Sep 2012 12:18:45 +0000 (+0200) Subject: new check_samples function X-Git-Tag: 0.3.3^2~3 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=dc24f84a7ea327f88165312c68c45d00f15cedc1;p=timeside.git new check_samples function --- diff --git a/tests/samples/guitar.wav b/tests/samples/guitar.wav deleted file mode 100644 index b5a9e80..0000000 Binary files a/tests/samples/guitar.wav and /dev/null differ diff --git a/tests/samples/sweep.flac b/tests/samples/sweep.flac deleted file mode 100644 index decee06..0000000 Binary files a/tests/samples/sweep.flac and /dev/null differ diff --git a/tests/samples/sweep.mp3 b/tests/samples/sweep.mp3 deleted file mode 100644 index dc75fe0..0000000 Binary files a/tests/samples/sweep.mp3 and /dev/null differ diff --git a/tests/samples/sweep.ogg b/tests/samples/sweep.ogg deleted file mode 100644 index e30bf99..0000000 Binary files a/tests/samples/sweep.ogg and /dev/null differ diff --git a/tests/samples/sweep.wav b/tests/samples/sweep.wav deleted file mode 100644 index fc28a32..0000000 Binary files a/tests/samples/sweep.wav and /dev/null differ diff --git a/tests/samples/sweep_source.wav b/tests/samples/sweep_source.wav deleted file mode 100644 index 5dcf9ba..0000000 Binary files a/tests/samples/sweep_source.wav and /dev/null differ diff --git a/tests/tools.py b/tests/tools.py new file mode 100644 index 0000000..63a0f59 --- /dev/null +++ b/tests/tools.py @@ -0,0 +1,20 @@ +import os +import urllib + +def check_samples(): + url = 'http://github.com/yomguy/timeside-samples/raw/master/samples/' + samples = ['guitar.wav', 'sweep.wav', 'sweep.flac', 'sweep.ogg', 'sweep.mp3', 'sweep_source.wav'] + path = os.path.normpath(os.path.dirname(__file__)) + dir = path + os.sep + 'samples' + + if not os.path.exists(dir): + os.makedirs(dir) + + for sample in samples: + path = dir + os.sep + sample + if not os.path.exists(path): + print 'downloading: ' + sample + f = open(path, 'w') + u = urllib.urlopen(url+sample) + f.write(u.read()) + f.close() diff --git a/tests/unit_timeside.py b/tests/unit_timeside.py index 09bc2d6..f31ac4c 100644 --- a/tests/unit_timeside.py +++ b/tests/unit_timeside.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import unittest -import sys +import os, sys import time +from tools import * class TestCase(unittest.TestCase): @@ -98,16 +99,19 @@ class _WritelnDecorator: if arg: self.write(arg) self.write('\n') # text-mode streams translate to \r\n if needed + class TestRunner: """A test runner class that displays results in textual form. It prints out the names of tests as they are run, errors as they occur, and a summary of the results at the end of the test run. """ + def __init__(self, stream=sys.stderr, descriptions=1, verbosity=2): self.stream = _WritelnDecorator(stream) self.descriptions = descriptions self.verbosity = verbosity + check_samples() def _makeResult(self): return _TextTestResult(self.stream, self.descriptions, self.verbosity)