[Python-modules-commits] [speechrecognition-python] 01/02: Allow disabling tests

Ethan Ward ethanward-guest at moszumanska.debian.org
Fri Sep 1 23:13:59 UTC 2017


This is an automated email from the git hooks/post-receive script.

ethanward-guest pushed a commit to branch patch-queue/master
in repository speechrecognition-python.

commit 71ddf67f39b5c2e58f9ff84e733b56235e3d57b1
Author: Ethan Ward <ethan.ward at mycroft.ai>
Date:   Fri Sep 1 12:16:56 2017 -0500

    Allow disabling tests
    
    Fix typos
---
 tests/test_audio.py            | 6 +++++-
 tests/test_recognition.py      | 4 ++++
 tests/test_special_features.py | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/test_audio.py b/tests/test_audio.py
index 4a18860..fccfc16 100644
--- a/tests/test_audio.py
+++ b/tests/test_audio.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 
 import unittest
-from os import path
+from os import path, environ
 
 import speech_recognition as sr
 
@@ -98,6 +98,7 @@ class TestAudioFile(unittest.TestCase):
         self.assertEqual(audio.sample_width, 2)
         self.assertSimilar(audio.get_raw_data()[:32], b"\x00\x00\xfe\xff\x02\x00\xfe\xff\xff\xff\x04\x00\xfa\xff\x04\x00\xfa\xff\t\x00\xf6\xff\n\x00\xfa\xff\xff\xff\x08\x00\xf5\xff")
 
+    @unittest.skipIf(environ.get("FLAC_TEST_SKIP", False), "Skipping flac tests")
     def test_flac_mono_16_bit(self):
         r = sr.Recognizer()
         with sr.AudioFile(path.join(path.dirname(path.realpath(__file__)), "audio-mono-16-bit-44100Hz.flac")) as source: audio = r.record(source)
@@ -106,6 +107,7 @@ class TestAudioFile(unittest.TestCase):
         self.assertEqual(audio.sample_width, 2)
         self.assertSimilar(audio.get_raw_data()[:32], b"\x00\x00\xff\xff\x01\x00\xff\xff\x00\x00\x01\x00\xfe\xff\x02\x00\xfc\xff\x06\x00\xf9\xff\x06\x00\xfe\xff\xfe\xff\x05\x00\xfa\xff")
 
+    @unittest.skipIf(environ.get("FLAC_TEST_SKIP", False), "Skipping flac tests")
     def test_flac_mono_24_bit(self):
         r = sr.Recognizer()
         with sr.AudioFile(path.join(path.dirname(path.realpath(__file__)), "audio-mono-24-bit-44100Hz.flac")) as source: audio = r.record(source)
@@ -116,6 +118,7 @@ class TestAudioFile(unittest.TestCase):
         else:
             self.assertSimilar(audio.get_raw_data()[:32], b"\x00\x00\x00\x00\x00\xff\xfe\xff\x00\x02\x01\x00\x00\xfd\xfe\xff\x00\x04\x00\x00\x00\xfc\x00\x00\x00\x04\xfe\xff\x00\xfb\x00\x00")
 
+    @unittest.skipIf(environ.get("FLAC_TEST_SKIP", False), "Skipping flac tests")
     def test_flac_stereo_16_bit(self):
         r = sr.Recognizer()
         with sr.AudioFile(path.join(path.dirname(path.realpath(__file__)), "audio-stereo-16-bit-44100Hz.flac")) as source: audio = r.record(source)
@@ -124,6 +127,7 @@ class TestAudioFile(unittest.TestCase):
         self.assertEqual(audio.sample_width, 2)
         self.assertSimilar(audio.get_raw_data()[:32], b"\xff\xff\xff\xff\x02\x00\xfe\xff\x00\x00\x01\x00\xfd\xff\x01\x00\xff\xff\x04\x00\xfa\xff\x05\x00\xff\xff\xfd\xff\x08\x00\xf6\xff")
 
+    @unittest.skipIf(environ.get("FLAC_TEST_SKIP", False), "Skipping flac tests")
     def test_flac_stereo_24_bit(self):
         r = sr.Recognizer()
         with sr.AudioFile(path.join(path.dirname(path.realpath(__file__)), "audio-stereo-24-bit-44100Hz.flac")) as source: audio = r.record(source)
diff --git a/tests/test_recognition.py b/tests/test_recognition.py
index 269dc00..4c78c99 100644
--- a/tests/test_recognition.py
+++ b/tests/test_recognition.py
@@ -13,21 +13,25 @@ class TestRecognition(unittest.TestCase):
         self.AUDIO_FILE_FR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "french.aiff")
         self.AUDIO_FILE_ZH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "chinese.flac")
 
+    @unittest.skipIf(os.environ.get("POCKETSPHINX_TEST_SKIP"), "Skipping pocketsphinx tests")
     def test_sphinx_english(self):
         r = sr.Recognizer()
         with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)
         self.assertEqual(r.recognize_sphinx(audio), "wanted to three")
 
+    @unittest.skipIf(os.environ.get("GOOGLE_TEST_SKIP",False), "Requires internet connection")
     def test_google_english(self):
         r = sr.Recognizer()
         with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)
         self.assertEqual(r.recognize_google(audio), "one two three")
 
+    @unittest.skipIf(os.environ.get("GOOGLE_TEST_SKIP",False), "Requires internet connection")
     def test_google_french(self):
         r = sr.Recognizer()
         with sr.AudioFile(self.AUDIO_FILE_FR) as source: audio = r.record(source)
         self.assertEqual(r.recognize_google(audio, language="fr-FR"), u"et c'est la dictée numéro 1")
 
+    @unittest.skipIf(os.environ.get("GOOGLE_TEST_SKIP",False), "Requires internet connection")
     def test_google_chinese(self):
         r = sr.Recognizer()
         with sr.AudioFile(self.AUDIO_FILE_ZH) as source: audio = r.record(source)
diff --git a/tests/test_special_features.py b/tests/test_special_features.py
index c77ab44..a4018d3 100644
--- a/tests/test_special_features.py
+++ b/tests/test_special_features.py
@@ -11,6 +11,7 @@ class TestSpecialFeatures(unittest.TestCase):
     def setUp(self):
         self.AUDIO_FILE_EN = os.path.join(os.path.dirname(os.path.realpath(__file__)), "english.wav")
 
+    @unittest.skipIf(os.environ.get('POCKETSPHINX_TEST_SKIP', False),"Skipping pocketsphinx tests")
     def test_sphinx_keywords(self):
         r = sr.Recognizer()
         with sr.AudioFile(self.AUDIO_FILE_EN) as source: audio = r.record(source)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/speechrecognition-python.git



More information about the Python-modules-commits mailing list