]> git.parisson.com Git - timeside.git/commitdiff
Doctest: Fix path issue for local test data
authorThomas Fillon <thomas@parisson.com>
Mon, 24 Mar 2014 13:50:36 +0000 (14:50 +0100)
committerThomas Fillon <thomas@parisson.com>
Mon, 24 Mar 2014 13:50:36 +0000 (14:50 +0100)
Use doctest.tesmod() `extraglobs` parameter to pass absolute data path to the doctest module. This works from both module directory or tests directory

timeside/analyzer/core.py
timeside/decoder/utils.py
timeside/encoder/audiosink.py

index 8d71572f284a3bd61426b332e587dc1ac6aef194..6ba2b902d9671ed722752d739a304062c141f822 100644 (file)
@@ -857,8 +857,8 @@ class AnalyzerResultContainer(dict):
 
     '''
     >>> 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()
@@ -1118,7 +1118,11 @@ class Analyzer(Processor):
 
         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)
index a776e15d53d41b60f2b30f53171d27f7251ad3ea..cb8c4183a812b67ba4727d1a729d021230c96d04 100644 (file)
@@ -174,7 +174,7 @@ def sha1sum_file(filename):
     '''
     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
     '''
@@ -196,7 +196,7 @@ def sha1sum_url(url):
     >>> 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
@@ -229,6 +229,8 @@ def sha1sum_numpy(np_array):
     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')}
index 611f51a4c8bc7eee767b5d39cc6049f59aac9108..b7e6531c1d3e75ab21c7852964fba2c0c276b089 100644 (file)
@@ -32,8 +32,8 @@ class AudioSink(GstEncoder):
 
 
     >>> 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
     """
@@ -95,6 +95,12 @@ class AudioSink(GstEncoder):
         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)