@@ -29,11 +29,9 @@ class PkgInstallTestBase(unittest.TestCase):
2929 def setUpClass (cls ):
3030 cls .runfiles = runfiles .Create ()
3131 # Somewhat of an implementation detail, but it works. I think.
32- manifest_file = cls .runfiles .Rlocation (
33- "rules_pkg/tests/install/test_installer_install_script-install-manifest.json"
34- )
32+ manifest_file = cls .runfiles .Rlocation ("rules_pkg/tests/install/test_installer_install_script-install-manifest.json" )
3533
36- with open (manifest_file , "r" ) as fh :
34+ with open (manifest_file , 'r' ) as fh :
3735 manifest_entries = manifest .read_entries_from (fh )
3836 cls .manifest_data = {}
3937
@@ -48,15 +46,12 @@ def setUpClass(cls):
4846 super ().setUpClass ()
4947 env = {}
5048 env .update (cls .runfiles .EnvVars ())
51- subprocess .check_call (
52- [
53- cls .runfiles .Rlocation ("rules_pkg/tests/install/test_installer" ),
54- "--destdir" ,
55- cls .installdir ,
56- "--verbose" ,
57- ],
58- env = env ,
59- )
49+ subprocess .check_call ([
50+ cls .runfiles .Rlocation ("rules_pkg/tests/install/test_installer" ),
51+ "--destdir" , cls .installdir ,
52+ "--verbose" ,
53+ ],
54+ env = env )
6055
6156 def entity_type_at_path (self , path ):
6257 if path .is_symlink ():
@@ -74,46 +69,37 @@ def assertEntryTypeMatches(self, entry, actual_path):
7469 actual_entry_type = self .entity_type_at_path (actual_path )
7570
7671 # TreeArtifacts looks like directories.
77- if (
78- entry .type == manifest .ENTRY_IS_TREE
79- and actual_entry_type == manifest .ENTRY_IS_DIR
80- ):
72+ if (entry .type == manifest .ENTRY_IS_TREE and
73+ actual_entry_type == manifest .ENTRY_IS_DIR ):
8174 return
8275
83- self .assertEqual (
84- actual_entry_type ,
85- entry .type ,
86- "Entity {} should be a {}, but was actually {}" .format (
87- entry .dest ,
88- manifest .entry_type_to_string (entry .type ),
89- manifest .entry_type_to_string (actual_entry_type ),
90- ),
91- )
92-
93- def assertEntryModeMatches (
94- self , entry , actual_path , is_tree_artifact_content = False
95- ):
76+ self .assertEqual (actual_entry_type , entry .type ,
77+ "Entity {} should be a {}, but was actually {}" .format (
78+ entry .dest ,
79+ manifest .entry_type_to_string (entry .type ),
80+ manifest .entry_type_to_string (actual_entry_type ),
81+ ))
82+
83+ def assertEntryModeMatches (self , entry , actual_path ,
84+ is_tree_artifact_content = False ):
9685 # TODO: permissions in windows are... tricky. Don't bother
9786 # testing for them if we're in it for the time being
98- if os .name == "nt" :
87+ if os .name == 'nt' :
9988 return
10089
10190 actual_mode = stat .S_IMODE (os .stat (actual_path , follow_symlinks = False ).st_mode )
10291 expected_mode = int (entry .mode , 8 )
10392
104- if not is_tree_artifact_content and entry .type == manifest .ENTRY_IS_TREE :
93+ if (not is_tree_artifact_content and
94+ entry .type == manifest .ENTRY_IS_TREE ):
10595 expected_mode |= 0o555
10696
107- self .assertEqual (
108- actual_mode ,
109- expected_mode ,
97+ self .assertEqual (actual_mode , expected_mode ,
11098 "Entry {}{} has mode {:04o}, expected {:04o}" .format (
111- entry .dest ,
112- f" ({ actual_path } )" if is_tree_artifact_content else "" ,
113- actual_mode ,
114- expected_mode ,
115- ),
116- )
99+ entry .dest ,
100+ f" ({ actual_path } )" if is_tree_artifact_content else "" ,
101+ actual_mode , expected_mode ,
102+ ))
117103
118104 def _find_tree_entry (self , path , owned_trees ):
119105 for tree_root in owned_trees :
@@ -122,7 +108,7 @@ def _find_tree_entry(self, path, owned_trees):
122108 return None
123109
124110 def _path_starts_with (self , path , other ):
125- return path .parts [: len (other .parts )] == other .parts
111+ return path .parts [:len (other .parts )] == other .parts
126112
127113 def test_manifest_matches (self ):
128114 unowned_dirs = set ()
@@ -179,8 +165,7 @@ def test_manifest_matches(self):
179165 # prefix of some entity in the manifest.
180166 is_unowned = rel_root_path in unowned_dirs
181167 is_tree_intermediate_dir = bool (
182- self ._find_tree_entry (rel_root_path , owned_trees )
183- )
168+ self ._find_tree_entry (rel_root_path , owned_trees ))
184169 self .assertTrue (is_unowned or is_tree_intermediate_dir )
185170
186171 for f in files :
@@ -211,9 +196,8 @@ def test_manifest_matches(self):
211196
212197 if entity_tree_root :
213198 entry = owned_trees [entity_tree_root ]
214- self .assertEntryModeMatches (
215- entry , fpath , is_tree_artifact_content = True
216- )
199+ self .assertEntryModeMatches (entry , fpath ,
200+ is_tree_artifact_content = True )
217201
218202 found_entries [rel_fpath ] = True
219203
@@ -230,15 +214,12 @@ def test_wipe(self):
230214 self .installdir .mkdir (exist_ok = True )
231215 (self .installdir / "should_be_deleted.txt" ).touch ()
232216
233- subprocess .check_call (
234- [
235- self .runfiles .Rlocation ("rules_pkg/tests/install/test_installer" ),
236- "--destdir" ,
237- self .installdir ,
238- "--wipe_destdir" ,
239- ],
240- env = self .runfiles .EnvVars (),
241- )
217+ subprocess .check_call ([
218+ self .runfiles .Rlocation ("rules_pkg/tests/install/test_installer" ),
219+ "--destdir" , self .installdir ,
220+ "--wipe_destdir" ,
221+ ],
222+ env = self .runfiles .EnvVars ())
242223 self .assertFalse ((self .installdir / "should_be_deleted.txt" ).exists ())
243224
244225
0 commit comments