Testing¶
WRTKit includes a comprehensive test suite to ensure reliability.
Running Tests¶
Install Development Dependencies¶
Run All Tests¶
Run with Verbose Output¶
Run with Coverage¶
View coverage report:
Run Specific Tests¶
# Test a specific file
pytest tests/test_network.py
# Test a specific function
pytest tests/test_network.py::test_device_creation
# Test a specific class
pytest tests/test_config.py::TestUCIConfig
Test Structure¶
tests/
├── __init__.py
├── test_config.py # Main configuration tests
├── test_network.py # Network configuration tests
├── test_wireless.py # Wireless configuration tests
├── test_dhcp.py # DHCP configuration tests
└── test_firewall.py # Firewall configuration tests
Writing Tests¶
Basic Test¶
def test_network_interface():
from wrtkit import UCIConfig
config = UCIConfig()
config.network.interface("lan") \
.device("eth0") \
.proto("static") \
.ipaddr("192.168.1.1")
commands = config.get_all_commands()
assert len(commands) > 0
assert any("network.lan.ipaddr" in cmd.path for cmd in commands)
Test with Assertions¶
def test_wireless_configuration():
from wrtkit.wireless import WirelessConfig
from wrtkit.base import UCICommand
wireless = WirelessConfig()
wireless.radio("radio0").channel(11).htmode("HT20")
commands = wireless.get_commands()
assert commands[0] == UCICommand("set", "wireless.radio0", "wifi-device")
assert any(cmd.path == "wireless.radio0.channel" and cmd.value == "11"
for cmd in commands)
Code Quality¶
Linting¶
Code Formatting¶
Type Checking¶
Continuous Integration¶
Tests run automatically on: - Every push to main - Every pull request - Multiple Python versions (3.8, 3.9, 3.10, 3.11, 3.12)
See the GitHub Actions workflow in .github/workflows/docs.yml for CI configuration.
See Also¶
- Contributing - Contribution guidelines
- Publishing - Publishing to PyPI