77from functools import partial , wraps
88from typing import Iterable , List , Optional
99
10- from autoparaselenium .browsers import chrome , firefox
1110from autoparaselenium .browser_pool import BrowserPool
11+ from autoparaselenium .browsers import chrome , firefox
1212from autoparaselenium .models import Conf , Extension
1313
14-
1514_browser_pool : Optional [BrowserPool ] = None
1615all_ = [chrome , firefox ]
1716
18- _test_count = 0 # manual reference counting since threading borks with destructors
17+ _test_count = 0 # manual reference counting since threading borks with destructors
1918
2019
21- def configure (* _ , extensions : List [Extension ] = [], headless = True , selenium_dir = "drivers" ):
20+ def configure (
21+ * _ , extensions : List [Extension ] = [], headless = True , selenium_dir = "drivers"
22+ ):
2223 global _browser_pool
2324
2425 if _browser_pool is not None :
@@ -37,7 +38,6 @@ def run_on(*browsers):
3738 if not browsers :
3839 raise TypeError ("Please specify a browser or browser list to run on" )
3940
40-
4141 if isinstance (browsers [0 ], Iterable ):
4242 browsers = [* it .chain (* browsers )]
4343
@@ -70,25 +70,28 @@ def __wrap_test(browser, test):
7070 _test_count += 1
7171
7272 if _browser_pool is None :
73- raise RuntimeError ("Please call autoparaselenium.configure() before creating tests" )
73+ raise RuntimeError (
74+ "Please call autoparaselenium.configure() before creating tests"
75+ )
7476
7577 def inner ():
7678 global _test_count
7779
7880 try :
7981 _test_count -= 1
8082 driver = _browser_pool .acquire (browser )
81- driver .get ("data:," ) # initialize driver website
83+ driver .get ("data:," ) # initialize driver website
8284 test (driver )
8385 finally :
8486 with suppress (Exception ):
8587 _browser_pool .release (driver )
8688
8789 if _test_count == 0 :
88- time .sleep (0.10 ) # idk but seems like it needs a bit of time before you can close the pool
90+ time .sleep (
91+ 0.10
92+ ) # idk but seems like it needs a bit of time before you can close the pool
8993 _browser_pool .clean_up ()
9094
91-
9295 inner .__name__ = f"{ test .__name__ } __{ 'chrome' if browser is chrome else 'firefox' } "
9396 inner .__doc__ = test .__doc__
9497
@@ -99,7 +102,7 @@ def __get_threads(args=sys.argv):
99102 if "--tests-per-worker" not in args :
100103 return 1
101104 tests_per_worker_idx = args .index ("--tests-per-worker" )
102- next_arg = "" .join (args [tests_per_worker_idx + 1 : tests_per_worker_idx + 2 ])
105+ next_arg = "" .join (args [tests_per_worker_idx + 1 : tests_per_worker_idx + 2 ])
103106 if next_arg == "auto" :
104107 return os .cpu_count () // 2 + 1
105108 try :
0 commit comments