Buckets:

download
raw
1.44 kB
import pytest
from privacy_guard.detectors.phone import PhoneDetector
@pytest.fixture
def detector():
return PhoneDetector()
def test_german_mobile(detector):
text = "Ruf mich an: 0171 1234567"
findings = detector.detect(text)
assert len(findings) == 1
assert findings[0].confidence == 1.0
def test_german_landline(detector):
text = "Tel: 030 12345678"
findings = detector.detect(text)
assert len(findings) == 1
def test_german_with_country_code(detector):
text = "Telefon: +49 171 1234567"
findings = detector.detect(text)
assert len(findings) == 1
def test_austrian_number(detector):
text = "+43 1 58858-0"
findings = detector.detect(text)
assert len(findings) == 1
def test_swiss_number(detector):
text = "+41 44 668 18 00"
findings = detector.detect(text)
assert len(findings) == 1
def test_no_false_positive_year(detector):
# A 4-digit year should not be a phone number
text = "Im Jahr 2024 war das so."
findings = detector.detect(text)
assert len(findings) == 0
def test_multiple_phones(detector):
text = "Büro: 030 12345678, Mobil: +49 171 1234567"
findings = detector.detect(text)
assert len(findings) == 2
def test_multiple_numbers_detected(detector):
text = "A: +49 30 12345678, B: +49 89 98765432"
findings = detector.detect(text)
assert len(findings) == 2
assert findings[0].text != findings[1].text

Xet Storage Details

Size:
1.44 kB
·
Xet hash:
dc817f2df455daad1c8d411882e287e3aa1eaabdbfbd4cb357b8dffbbd690fb3

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.