diff --git a/.gitignore b/.gitignore index 480df8e..560b9b2 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ venv/ demo.* .coverage coverage.xml +tests/demo.* diff --git a/tests/test_audio.py b/tests/test_audio.py index c0d82f5..ef08f98 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -1,7 +1,10 @@ # coding: utf-8 +import os from captcha.audio import AudioCaptcha +ROOT = os.path.abspath(os.path.dirname(__file__)) + def test_audio_generate(): captcha = AudioCaptcha() @@ -14,3 +17,10 @@ def test_audio_random(): captcha = AudioCaptcha() data = captcha.random(4) assert len(data) == 4 + + +def test_save_audio(): + captcha = AudioCaptcha() + filepath = os.path.join(ROOT, 'demo.wav') + captcha.write('1234', filepath) + assert os.path.isfile(filepath) diff --git a/tests/test_image.py b/tests/test_image.py index 13f7143..963453c 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -1,9 +1,19 @@ # coding: utf-8 +import os from captcha.image import ImageCaptcha +ROOT = os.path.abspath(os.path.dirname(__file__)) + def test_image_generate(): captcha = ImageCaptcha() data = captcha.generate('1234') assert hasattr(data, 'read') + + +def test_save_image(): + captcha = ImageCaptcha() + filepath = os.path.join(ROOT, 'demo.png') + captcha.write('1234', filepath) + assert os.path.isfile(filepath)