Skip to content

Commit

Permalink
Tests modification (#52)
Browse files Browse the repository at this point in the history
* fix : function_test.py updated

* fix : error_test.py updated

* doc : CHANGELOG.md updated
  • Loading branch information
sepandhaghighi authored Aug 17, 2024
1 parent 48a6881 commit 07ea3ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `engine` parameter added to `play` function
- `engine` parameter added to `NavaThread` class
- `README.md` modified
- Test system modified
- `__play_win` function renamed to `__play_winsound`
- `__play_mac` function renamed to `__play_afplay`
- `__play_linux` function renamed to `__play_alsa`
Expand Down
5 changes: 3 additions & 2 deletions test/error_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
>>> import os
>>> from nava import play, stop
>>> test_sound_path = os.path.join("others", "test.wav")
>>> play("test.wav")
Traceback (most recent call last):
...
Expand All @@ -14,11 +15,11 @@
Traceback (most recent call last):
...
nava.errors.NavaBaseError: Given sound id doesn't exist.
>>> play(os.path.join("others", "test.wav"), async_mode=False, loop=True)
>>> play(test_sound_path, async_mode=False, loop=True)
Traceback (most recent call last):
...
nava.errors.NavaBaseError: `loop` can not be set True when `async_mode` is False.
>>> play(os.path.join("others", "test.wav"), async_mode=True, loop=True, engine=2)
>>> play(test_sound_path, async_mode=True, loop=True, engine=2)
Traceback (most recent call last):
...
nava.errors.NavaBaseError: `engine` type must be `Engine` enum.
Expand Down
21 changes: 11 additions & 10 deletions test/function_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
>>> import sys
>>> import time
>>> import nava
>>> nava.play(os.path.join("others", "test.wav"))
>>> sound_id_1 = nava.play(os.path.join("others", "test.wav"), async_mode=True)
>>> test_sound_path = os.path.join("others", "test.wav")
>>> nava.play(test_sound_path)
>>> sound_id_1 = nava.play(test_sound_path, async_mode=True)
>>> sound_id_1 == 1001
True
>>> sound_id_2 = nava.play(os.path.join("others", "test.wav"), async_mode=True)
>>> sound_id_2 = nava.play(test_sound_path, async_mode=True)
>>> sound_id_2 == 1002
True
>>> sound_id_3 = nava.play(os.path.join("others", "test.wav"), async_mode=True)
>>> sound_id_3 = nava.play(test_sound_path, async_mode=True)
>>> sound_id_3 == 1003
True
>>> sound_id_4 = nava.play(os.path.join("others", "test.wav"), async_mode=True, loop=True)
>>> sound_id_4 = nava.play(test_sound_path, async_mode=True, loop=True)
>>> sound_id_4 == 1004
True
>>> nava.stop(sound_id_1)
>>> nava.stop(sound_id_4)
>>> for i in range(40):
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True)
... sound_id = nava.play(test_sound_path, async_mode=True)
... time.sleep(0.2)
>>> time.sleep(1)
>>> nava.stop_all()
Expand All @@ -30,12 +31,12 @@
True
>>> sys_platform = sys.platform
>>> if sys_platform == "win32":
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True, engine=nava.Engine.WINSOUND)
... sound_id = nava.play(test_sound_path, async_mode=True, engine=nava.Engine.WINSOUND)
... elif sys_platform == "darwin":
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True, engine=nava.Engine.AFPLAY)
... sound_id = nava.play(test_sound_path, async_mode=True, engine=nava.Engine.AFPLAY)
... else:
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True, engine=nava.Engine.ALSA)
>>> nava.functions.play_cli(os.path.join("others", "test.wav"))
... sound_id = nava.play(test_sound_path, async_mode=True, engine=nava.Engine.ALSA)
>>> nava.functions.play_cli(test_sound_path)
>>> nava.functions.nava_help()
<BLANKLINE>
A Python library for playing sound everywhere natively and securely.
Expand Down

0 comments on commit 07ea3ee

Please sign in to comment.