Skip to content

Commit

Permalink
test: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 18, 2024
1 parent 5864c0e commit 8ce85d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ venv/
demo.*
.coverage
coverage.xml
tests/demo.*
10 changes: 10 additions & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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)
10 changes: 10 additions & 0 deletions tests/test_image.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8ce85d2

Please sign in to comment.