This directory contains tests for the LabSound Python bindings.
You can run the tests using Python's unittest framework:
# Run all tests
python -m unittest discover -s tests
# Run a specific test file
python -m unittest tests/test_basic.py
# Run a specific test case
python -m unittest tests.test_basic.TestAudioContext
# Run a specific test method
python -m unittest tests.test_basic.TestAudioContext.test_create_contextThe tests are organized into test cases for each major component of the library:
TestAudioContext: Tests for the AudioContext classTestOscillatorNode: Tests for the OscillatorNode classTestGainNode: Tests for the GainNode classTestConnections: Tests for connecting and disconnecting nodes
When adding new tests, follow these guidelines:
- Create a new test file for each major component or feature
- Use descriptive test method names that explain what is being tested
- Include docstrings for test classes and methods
- Keep tests focused on a single aspect of functionality
- Use assertions to verify expected behavior
Example:
import unittest
import labsound as ls
class TestMyFeature(unittest.TestCase):
"""Tests for MyFeature."""
def test_specific_behavior(self):
"""Test that MyFeature behaves as expected in a specific scenario."""
# Test code here
self.assertEqual(expected, actual)The tests require:
- Python 3.7+
- LabSoundPy installed (either in development mode or from a package)
- unittest (part of the Python standard library)