Use doctest.tesmod() `extraglobs` parameter to pass absolute data path to the doctest module. This works from both module directory or tests directory
'''
>>> import timeside
- >>> wavFile = 'http://github.com/yomguy/timeside-samples/raw/master/samples/sweep.mp3'
- >>> d = timeside.decoder.FileDecoder(wavFile)
+ >>> wav_file = 'tests/samples/sweep.mp3' # doctest: +SKIP
+ >>> d = timeside.decoder.FileDecoder(wav_file)
>>> a = timeside.analyzer.Analyzer()
>>> (d|a).run()
return result
+import os
+DOCTEST_ALIAS = {'wav_file': os.path.join(os.path.dirname(__file__),
+ '../../tests/samples/sweep.mp3')}
+
if __name__ == "__main__":
import doctest
- doctest.testmod()
+ doctest.testmod(extraglobs=DOCTEST_ALIAS)
'''
Return the secure hash digest with sha1 algorithm for a given file
- >>> wav_file = '../../tests/samples/guitar.wav' # doctest: +SKIP
+ >>> wav_file = 'tests/samples/guitar.wav' # doctest: +SKIP
>>> print sha1sum_file(wav_file)
08301c3f9a8d60926f31e253825cc74263e52ad1
'''
>>> url = 'https://github.com/yomguy/timeside-samples/raw/master/samples/guitar.wav'
>>> print sha1sum_url(url)
08301c3f9a8d60926f31e253825cc74263e52ad1
- >>> wav_file = '../../tests/samples/guitar.wav' # doctest: +SKIP
+ >>> wav_file = 'tests/samples/guitar.wav' # doctest: +SKIP
>>> uri = get_uri(wav_file)
>>> print sha1sum_url(uri)
08301c3f9a8d60926f31e253825cc74263e52ad1
import hashlib
return hashlib.sha1(np_array.view(np.uint8)).hexdigest()
+
+# Define global variables for use with doctest
import os
DOCTEST_ALIAS = {'wav_file': os.path.join(os.path.dirname(__file__),
'../../tests/samples/guitar.wav')}
>>> import timeside
- >>> wavfile = 'https://github.com/yomguy/timeside-samples/raw/master/samples/guitar.wav'
- >>> d = timeside.decoder.FileDecoder(wavfile)
+ >>> wav_file = 'tests/samples/guitar.wav' # doctest: +SKIP
+ >>> d = timeside.decoder.FileDecoder(wav_file)
>>> e = timeside.encoder.AudioSink()
>>> (d|e).run() # doctest: +SKIP
"""
self.metadata = metadata
+# Define global variables for use with doctest
+import os
+DOCTEST_ALIAS = {'wav_file': os.path.join(os.path.dirname(__file__),
+ '../../tests/samples/guitar.wav')}
+
if __name__ == "__main__":
import doctest
- doctest.testmod()
+
+ doctest.testmod(extraglobs=DOCTEST_ALIAS)