mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
refactor: improve test structure in mDNS tests
This commit is contained in:
@ -1,22 +1,22 @@
|
||||
"""
|
||||
Basic unit tests for mDNS utils module.
|
||||
"""
|
||||
|
||||
import string
|
||||
import pytest
|
||||
|
||||
from libp2p.discovery.mdns.utils import stringGen
|
||||
|
||||
|
||||
class TestStringGen:
|
||||
"""Basic unit tests for stringGen function."""
|
||||
"""Unit tests for stringGen function."""
|
||||
|
||||
def test_stringgen_default_length(self):
|
||||
"""Test stringGen with default length (63)."""
|
||||
result = stringGen()
|
||||
|
||||
|
||||
assert isinstance(result, str)
|
||||
assert len(result) == 63
|
||||
|
||||
|
||||
# Check that all characters are from the expected charset
|
||||
charset = string.ascii_lowercase + string.digits
|
||||
for char in result:
|
||||
@ -26,13 +26,13 @@ class TestStringGen:
|
||||
"""Test stringGen with custom lengths."""
|
||||
# Test various lengths
|
||||
test_lengths = [1, 5, 10, 20, 50, 100]
|
||||
|
||||
|
||||
for length in test_lengths:
|
||||
result = stringGen(length)
|
||||
|
||||
|
||||
assert isinstance(result, str)
|
||||
assert len(result) == length
|
||||
|
||||
|
||||
# Check that all characters are from the expected charset
|
||||
charset = string.ascii_lowercase + string.digits
|
||||
for char in result:
|
||||
|
||||
Reference in New Issue
Block a user