mirror of
https://github.com/lepture/captcha.git
synced 2026-03-13 09:43:22 +08:00
test: add more tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,3 +21,4 @@ venv/
|
||||
demo.*
|
||||
.coverage
|
||||
coverage.xml
|
||||
tests/demo.*
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user