File tree Expand file tree Collapse file tree 5 files changed +60
-1
lines changed
Expand file tree Collapse file tree 5 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 2020 ],
2121 install_requires = [
2222 'requests'
23- ]
23+ ],
24+ extras_require = {
25+ 'dev' : [
26+ 'pytest' ,
27+ 'codetiming'
28+ ]
29+ },
2430)
Original file line number Diff line number Diff line change 1+ import pytest
2+ from tranco .tranco import Tranco
3+
4+
5+ @pytest .fixture (scope = "session" )
6+ def tranco ():
7+ t = Tranco (cache = True , cache_dir = '.tranco' )
8+ t .list () # prefetch list
9+ return t
10+
11+
12+ @pytest .fixture (scope = "session" )
13+ def tranco_list (tranco ):
14+ return tranco .list ()
15+
Original file line number Diff line number Diff line change 1+ import uuid
2+
3+
4+ def test_top_10 (tranco_list ):
5+ assert len (tranco_list .top (10 )) == 10
6+
7+
8+ def test_top_1000000 (tranco_list ):
9+ assert len (tranco_list .top (1000000 )) == 1000000
10+
11+
12+ def test_domain_rank (tranco_list ):
13+ top_1 = tranco_list .top (1 )[0 ]
14+ assert tranco_list .rank (top_1 ) == 1
15+
16+
17+ def test_domain_not_in_list_rank (tranco_list ):
18+ assert tranco_list .rank (f"domaindoesntexist{ uuid .uuid4 ().hex .upper ()[0 :6 ]} .com" ) == - 1
Original file line number Diff line number Diff line change 1+ from codetiming import Timer
2+ import pytest
3+
4+
5+ def test_performance_rank (tranco_list ):
6+ core_list = tranco_list .top (1000000 )
7+ # test dictionary
8+ timer = Timer (name = "class" , logger = None )
9+ timer .start ()
10+ for i , domain in enumerate (core_list , start = 1 ):
11+ assert i == tranco_list .rank (domain )
12+ print ("Rank:" , timer .stop ())
13+
14+
15+ def test_performance_top (tranco_list ):
16+ # test dictionary
17+ timer = Timer (name = "class" , logger = None )
18+ timer .start ()
19+ core_list = tranco_list .top (1000000 )
20+ print ("Top:" , timer .stop ())
You can’t perform that action at this time.
0 commit comments