1
1
from __future__ import annotations
2
2
3
+ import re
3
4
from typing import Any , Iterator , get_args
4
5
from unittest import mock
5
6
from unittest .mock import call
6
7
7
8
import pytest
8
- import regex
9
9
10
10
from crawlee ._request import UserData
11
11
from crawlee ._types import HttpHeaders , HttpMethod
@@ -172,11 +172,13 @@ async def test_actor_create_request_list_from_url_additional_inputs() -> None:
172
172
'http://a.com' ,
173
173
'http://www.something.com/somethignelse'
174
174
'http://www.something.com/somethignelse.txt' ,
175
- 'http://non-english-chars-áíéåü.com'
175
+ 'http://non-english-chars-áíéåü.com' ,
176
+ 'http://www.port.com:1234' ,
177
+ 'http://username:[email protected] '
176
178
])
177
179
def test_url_no_commas_regex_true_positives (true_positive : str ) -> None :
178
180
example_string = f'Some text { true_positive } some more text'
179
- matches = list (regex .finditer (URL_NO_COMMAS_REGEX , example_string ))
181
+ matches = list (re .finditer (URL_NO_COMMAS_REGEX , example_string ))
180
182
assert len (matches ) == 1
181
183
assert matches [0 ].group (0 ) == true_positive
182
184
@@ -190,12 +192,12 @@ def test_url_no_commas_regex_true_positives(true_positive: str) -> None:
190
192
])
191
193
def test_url_no_commas_regex_false_positives (false_positive : str ) -> None :
192
194
example_string = f'Some text { false_positive } some more text'
193
- matches = list (regex .findall (URL_NO_COMMAS_REGEX , example_string ))
195
+ matches = list (re .findall (URL_NO_COMMAS_REGEX , example_string ))
194
196
assert len (matches ) == 0
195
197
196
198
def test_url_no_commas_regex_multi_line () -> None :
197
199
true_positives = ('http://www.something.com' , 'http://www.else.com' )
198
200
example_string = 'Some text {} some more text \n Some new line text {} ...' .format (* true_positives )
199
- matches = list (regex .finditer (URL_NO_COMMAS_REGEX , example_string ))
201
+ matches = list (re .finditer (URL_NO_COMMAS_REGEX , example_string ))
200
202
assert len (matches ) == 2
201
203
assert {match .group (0 ) for match in matches } == set (true_positives )
0 commit comments