33import pytest
44
55from pywhat import regex_identifier
6- from pywhat .filter import Filter
6+ from pywhat .filter import Distribution , Filter
77from pywhat .helper import load_regexes
88
99database = load_regexes ()
1010r = regex_identifier .RegexIdentifier ()
11+ filter1 = Filter ({"MinRarity" : 0.0 })
12+ d = Distribution (filter1 )
13+ r_rarity_0 = regex_identifier .RegexIdentifier ()
1114
1215
1316def _assert_match_first_item (name , res ):
@@ -415,12 +418,12 @@ def test_youtube2():
415418
416419
417420def test_youtube_id ():
418- res = r .check (["dQw4w9WgXcQ" ])
421+ res = r .check (["dQw4w9WgXcQ" ], dist = d )
419422 _assert_match_first_item ("YouTube Video ID" , res )
420423
421424
422425def test_youtube_id2 ():
423- res = r .check (["078-05-1120" ])
426+ res = r .check (["078-05-1120" ], dist = d )
424427 assert "YouTube Video ID" not in res
425428
426429
@@ -533,35 +536,35 @@ def test_arn4():
533536
534537
535538def test_unix_timestamp ():
536- res = r .check (["1577836800" ]) # 2020-01-01
539+ res = r .check (["1577836800" ], dist = d ) # 2020-01-01
537540 keys = [m ["Regex Pattern" ]["Name" ] for m in res ]
538541 assert "Unix Timestamp" in keys
539542 assert "Recent Unix Timestamp" in keys
540543
541544
542545def test_unix_timestamp2 ():
543- res = r .check (["94694400" ]) # 1973-01-01
546+ res = r .check (["94694400" ], dist = d ) # 1973-01-01
544547 keys = [m ["Regex Pattern" ]["Name" ] for m in res ]
545548 assert "Unix Timestamp" in keys
546549 assert "Recent Unix Timestamp" not in keys
547550
548551
549552def test_unix_timestamp3 ():
550- res = r .check (["1234567" ]) # 7 numbers
553+ res = r .check (["1234567" ], dist = d ) # 7 numbers
551554 keys = [m ["Regex Pattern" ]["Name" ] for m in res ]
552555 assert "Unix Timestamp" not in keys
553556 assert "Recent Unix Timestamp" not in keys
554557
555558
556559def test_unix_timestamp4 ():
557- res = r .check (["1577836800000" ]) # 2020-01-01
560+ res = r .check (["1577836800000" ], dist = d ) # 2020-01-01
558561 keys = [m ["Regex Pattern" ]["Name" ] for m in res ]
559562 assert "Unix Millisecond Timestamp" in keys
560563 assert "Recent Unix Millisecond Timestamp" in keys
561564
562565
563566def test_unix_timestamp5 ():
564- res = r .check (["94694400000" ]) # 1973-01-01
567+ res = r .check (["94694400000" ], dist = d ) # 1973-01-01
565568 keys = [m ["Regex Pattern" ]["Name" ] for m in res ]
566569 assert "Unix Millisecond Timestamp" in keys
567570 assert "Recent Unix Millisecond Timestamp" not in keys
@@ -1006,7 +1009,7 @@ def test_turkish_id_number2():
10061009
10071010
10081011def test_turkish_tax_number ():
1009- res = r .check (["1234567890" ])
1012+ res = r .check (["1234567890" ], dist = d )
10101013 assert "Turkish Tax Number" in str (res )
10111014
10121015
@@ -1016,12 +1019,12 @@ def test_uuid():
10161019
10171020
10181021def test_objectid ():
1019- res = r .check (["5fc7c33a7ef88b139122a38a" ])
1022+ res = r_rarity_0 .check (["5fc7c33a7ef88b139122a38a" ], dist = d )
10201023 assert "ObjectID" in str (res )
10211024
10221025
10231026def test_ulid ():
1024- res = r .check (["01ERJ58HMWDN3VTRRHZQV2T5R5" ])
1027+ res = r_rarity_0 .check (["01ERJ58HMWDN3VTRRHZQV2T5R5" ], dist = d )
10251028 assert "ULID" in str (res )
10261029
10271030
0 commit comments