Download tests/test_regex.py from rottenstuff/cl: direct link, hf CLI and curl.
- Browser
- Download file 3.75 kB
-
https://huggingface.co/rottenstuff/cl/resolve/main/tests/test_regex.py
- Command line
-
hf download hf://rottenstuff/cl/tests/test_regex.py
-
curl -L -o test_regex.py https://huggingface.co/rottenstuff/cl/resolve/main/tests/test_regex.py
3.75 kB
| """ | |
| Юнит-тесты для regex-паттернов поиска URL в выводе туннельных утилит. | |
| Тесты не требуют сети или реальных процессов. | |
| """ | |
| import re | |
| import pytest | |
| # Cloudflared─── | |
| CF_PATTERN = r'(?P<url>https?://\S+\.trycloudflare\.com)' | |
| def test_cloudflared(text: str, expected: str) -> None: | |
| m = re.search(CF_PATTERN, text) | |
| assert m is not None, f'Паттерн не нашёл URL в: {text!r}' | |
| assert m.group() == expected | |
| # Bore | |
| BORE_PATTERN = r'bore\.pub:\d+' | |
| def test_bore(text: str, expected: str) -> None: | |
| m = re.search(BORE_PATTERN, text) | |
| assert m is not None | |
| assert m.group() == expected | |
| # MMAR | |
| def test_mmar(text: str, expected: str) -> None: | |
| m = re.search(r'(?P<url>https?://\S+\.mmar\.dev)', text) | |
| assert m is not None | |
| assert m.group() == expected | |
| # Tunnelite | |
| def test_tunnelite() -> None: | |
| text = 'Your public URL: https://random-words.tunnelite.com' | |
| m = re.search(r'(?P<url>https?://\S+\.tunnelite\.com)', text) | |
| assert m is not None | |
| assert m.group() == 'https://random-words.tunnelite.com' | |
| # Beeceptor | |
| def test_beeceptor() -> None: | |
| text = 'Tunnel running at https://my-endpoint.beeceptor.com' | |
| m = re.search(r'(?P<url>https?://\S+\.beeceptor\.com)', text) | |
| assert m is not None | |
| assert m.group() == 'https://my-endpoint.beeceptor.com' | |
| # Bore Digital── | |
| def test_boredigital() -> None: | |
| text = '| https://xyz123.bore.digital | active |' | |
| m = re.search(r'(?P<url>https://\S+\.bore\.digital)', text) | |
| assert m is not None | |
| assert m.group() == 'https://xyz123.bore.digital' | |
| # SSH-провайдеры | |
| def test_ssh_patterns(pattern: str, text: str, should_match: bool) -> None: | |
| m = re.search(pattern, text) | |
| if should_match: | |
| assert m is not None, f'{pattern!r} не нашёл совпадение в {text!r}' | |
| else: | |
| assert m is None, f'{pattern!r} не должен совпадать с {text!r}' | |