5555from .testutils import assert_run_python_script
5656from .testutils import check_deterministic_pickle
5757
58-
5958_TEST_GLOBAL_VARIABLE = "default_value"
6059_TEST_GLOBAL_VARIABLE2 = "another_value"
6160
@@ -354,7 +353,6 @@ class A:
354353 assert hasattr (A_roundtrip , "__firstlineno__" )
355354 assert A_roundtrip .__firstlineno__ == A .__firstlineno__
356355
357-
358356 def test_dynamically_generated_class_that_uses_super (self ):
359357 class Base :
360358 def method (self ):
@@ -1067,7 +1065,9 @@ def test_extended_arg(self):
10671065 def f():
10681066 x = {tup}
10691067 return zlib.crc32(bytes(bytearray(x)))
1070- """ .format (tup = ", " .join (names ))
1068+ """ .format (
1069+ tup = ", " .join (names )
1070+ )
10711071 exec (textwrap .dedent (code ), d , d )
10721072 f = d ["f" ]
10731073 res = f ()
@@ -1206,7 +1206,9 @@ def check_logger(self, name):
12061206 logging.basicConfig(level=logging.INFO)
12071207 logger = cloudpickle.loads(base64.b32decode(b'{}'))
12081208 logger.info('hello')
1209- """ .format (base64 .b32encode (dumped ).decode ("ascii" ))
1209+ """ .format (
1210+ base64 .b32encode (dumped ).decode ("ascii" )
1211+ )
12101212 proc = subprocess .Popen (
12111213 [sys .executable , "-W ignore" , "-c" , code ],
12121214 stdout = subprocess .PIPE ,
@@ -1506,7 +1508,8 @@ def __getattr__(self, name):
15061508
15071509 def test_importing_multiprocessing_does_not_impact_whichmodule (self ):
15081510 # non-regression test for #528
1509- script = textwrap .dedent ("""
1511+ script = textwrap .dedent (
1512+ """
15101513 import multiprocessing
15111514 import cloudpickle
15121515 from cloudpickle.cloudpickle import dumps
@@ -1516,7 +1519,8 @@ def test_importing_multiprocessing_does_not_impact_whichmodule(self):
15161519 dumps.__module__ = None
15171520
15181521 print(cloudpickle.cloudpickle._whichmodule(dumps, dumps.__name__))
1519- """ )
1522+ """
1523+ )
15201524 script_path = Path (self .tmpdir ) / "whichmodule_and_multiprocessing.py"
15211525 with open (script_path , mode = "w" ) as f :
15221526 f .write (script )
@@ -1530,7 +1534,6 @@ def test_importing_multiprocessing_does_not_impact_whichmodule(self):
15301534 self .assertEqual (proc .wait (), 0 , msg = "Stdout: " + str (out ))
15311535 self .assertEqual (out .strip (), b"cloudpickle.cloudpickle" )
15321536
1533-
15341537 def test_unrelated_faulty_module (self ):
15351538 # Check that pickling a dynamically defined function or class does not
15361539 # fail when introspecting the currently loaded modules in sys.modules
@@ -1733,7 +1736,9 @@ def f5(x):
17331736
17341737 cloned = subprocess_pickle_echo(f5, protocol={protocol})
17351738 assert cloned(7) == f5(7) == 7
1736- """ .format (protocol = self .protocol )
1739+ """ .format (
1740+ protocol = self .protocol
1741+ )
17371742 assert_run_python_script (textwrap .dedent (code ))
17381743
17391744 def test_interactively_defined_global_variable (self ):
@@ -1872,7 +1877,9 @@ def interactive_function(x):
18721877 # previous definition of `interactive_function`:
18731878
18741879 assert w.run(wrapper_func, 41) == 40
1875- """ .format (protocol = self .protocol )
1880+ """ .format (
1881+ protocol = self .protocol
1882+ )
18761883 assert_run_python_script (code )
18771884
18781885 def test_interactive_remote_function_calls_no_side_effect (self ):
@@ -1916,7 +1923,9 @@ def is_in_main(name):
19161923 assert is_in_main("GLOBAL_VARIABLE")
19171924 assert not w.run(is_in_main, "GLOBAL_VARIABLE")
19181925
1919- """ .format (protocol = self .protocol )
1926+ """ .format (
1927+ protocol = self .protocol
1928+ )
19201929 assert_run_python_script (code )
19211930
19221931 def test_interactive_dynamic_type_and_remote_instances (self ):
@@ -1955,7 +1964,9 @@ def echo(*args):
19551964 assert isinstance(c1, CustomCounter)
19561965 assert isinstance(c2, CustomCounter)
19571966
1958- """ .format (protocol = self .protocol )
1967+ """ .format (
1968+ protocol = self .protocol
1969+ )
19591970 assert_run_python_script (code )
19601971
19611972 def test_interactive_dynamic_type_and_stored_remote_instances (self ):
@@ -2032,7 +2043,9 @@ class A:
20322043 # method:
20332044 assert w.run(lambda obj_id: lookup(obj_id).echo(43), id2) == 43
20342045
2035- """ .format (protocol = self .protocol )
2046+ """ .format (
2047+ protocol = self .protocol
2048+ )
20362049 assert_run_python_script (code )
20372050
20382051 def test_dynamic_func_deterministic_roundtrip (self ):
@@ -2220,7 +2233,9 @@ def process_data():
22202233 # iterations instead of 100 as used now (100x more data)
22212234 assert growth < 5e7, growth
22222235
2223- """ .format (protocol = self .protocol )
2236+ """ .format (
2237+ protocol = self .protocol
2238+ )
22242239 assert_run_python_script (code )
22252240
22262241 def test_pickle_reraise (self ):
@@ -2422,7 +2437,9 @@ def check_positive(x):
24222437
24232438 result = w.run(check_positive, 1)
24242439 assert result is Color.BLUE
2425- """ .format (protocol = self .protocol )
2440+ """ .format (
2441+ protocol = self .protocol
2442+ )
24262443 assert_run_python_script (code )
24272444
24282445 def test_relative_import_inside_function (self ):
@@ -2476,7 +2493,9 @@ def f(a, /, b=1):
24762493 with pytest.raises(TypeError):
24772494 func(a=2)
24782495
2479- """ .format (protocol = self .protocol )
2496+ """ .format (
2497+ protocol = self .protocol
2498+ )
24802499 assert_run_python_script (textwrap .dedent (code ))
24812500
24822501 def test___reduce___returns_string (self ):
@@ -3049,7 +3068,9 @@ def echo(*args):
30493068 cloned_value, cloned_type = w.run(echo, value, SampleDataclass)
30503069 assert cloned_type is SampleDataclass
30513070 assert isinstance(cloned_value, SampleDataclass)
3052- """ .format (protocol = self .protocol )
3071+ """ .format (
3072+ protocol = self .protocol
3073+ )
30533074 assert_run_python_script (code )
30543075
30553076
0 commit comments