2020import heapq
2121import inspect
2222import unittest
23-
2423from collections .abc import MutableSet
2524
2625# same format as sys.version_info: "A tuple containing the five components of
@@ -138,7 +137,7 @@ def _kruskals_graph_MST(graph):
138137 edges = set ()
139138 for from_node , to_nodes in graph .items ():
140139 for to_node , value in to_nodes .items ():
141- edge = (value ,) + tuple (sorted ([from_node , to_node ]))
140+ edge = (value , * tuple (sorted ([from_node , to_node ]) ))
142141 edges .add (edge )
143142 edges = list (edges )
144143 heapq .heapify (edges )
@@ -529,7 +528,7 @@ class TestLoader(unittest.TestLoader):
529528 suiteClass = OptimisingTestSuite
530529
531530
532- class TestResourceManager ( object ) :
531+ class TestResourceManager :
533532 """A manager for resources that can be shared across tests.
534533
535534 ResourceManagers can report activity to a TestResult. The methods
@@ -797,7 +796,7 @@ def __init__(
797796 be embedded in the string returned by the id() method, to identify
798797 the generic resource. Defaults to '__name__'.
799798 """
800- super (GenericResource , self ).__init__ ()
799+ super ().__init__ ()
801800 self .resource_factory = resource_factory
802801 self .setup_method_name = setup_method_name
803802 self .teardown_method_name = teardown_method_name
@@ -819,9 +818,8 @@ def id(self):
819818
820819 :see: The `id_attribute_name` parameter.
821820 """
822- return "%s[%s]" % (
823- super (GenericResource , self ).id (),
824- getattr (self .resource_factory , self .id_attribute_name ),
821+ return (
822+ f"{ super ().id ()} [{ getattr (self .resource_factory , self .id_attribute_name )} ]"
825823 )
826824
827825
@@ -851,7 +849,7 @@ def __init__(self, fixture):
851849
852850 :param fixture: The fixture to wrap.
853851 """
854- super (FixtureResource , self ).__init__ ()
852+ super ().__init__ ()
855853 self .fixture = fixture
856854
857855 def clean (self , resource ):
@@ -866,7 +864,7 @@ def id(self):
866864
867865 The default is to call str(fixture) to get such information.
868866 """
869- return "%s[%s]" % ( super (FixtureResource , self ).id (), str ( self .fixture ))
867+ return f" { super ().id ()} [ { self .fixture !s } ]"
870868
871869 def _reset (self , resource , dependency_resources ):
872870 self .fixture .reset ()
@@ -896,15 +894,15 @@ class is neded, or you can use multiple inheritance and call into
896894 resources = []
897895
898896 def setUp (self ):
899- super (ResourcedTestCase , self ).setUp ()
897+ super ().setUp ()
900898 self .setUpResources ()
901899
902900 def setUpResources (self ):
903901 setUpResources (self , self .resources , _get_result ())
904902
905903 def tearDown (self ):
906904 self .tearDownResources ()
907- super (ResourcedTestCase , self ).tearDown ()
905+ super ().tearDown ()
908906
909907 def tearDownResources (self ):
910908 tearDownResources (self , self .resources , _get_result ())
@@ -946,7 +944,7 @@ def neededResources(resources):
946944 dependencies = neededResources (
947945 [dependency for name , dependency in resource .resources ]
948946 )
949- for resource in dependencies + [ resource ]:
947+ for resource in [ * dependencies , resource ]:
950948 if resource in seen :
951949 continue
952950 seen .add (resource )
0 commit comments