@@ -77,34 +77,40 @@ def test_unshare_user_namespace(self) -> None:
7777 self .assertNotEqual (uid_before_test , uid_after )
7878
7979 def test_errors (self ) -> None :
80- with self .subTest ("Unshare with invalid value" ), self .assertRaisesRegex (
81- OSError , "22"
80+ with (
81+ self .subTest ("Unshare with invalid value" ),
82+ self .assertRaisesRegex (OSError , "22" ),
8283 ):
8384 unshare (- 1 )
8485
8586 with TemporaryFile () as temp_f :
86- with self .subTest ("setns on invalid fd" ), self .assertRaisesRegex (
87- OSError , "22"
87+ with (
88+ self .subTest ("setns on invalid fd" ),
89+ self .assertRaisesRegex (OSError , "22" ),
8890 ):
8991 setns (temp_f .fileno (), 0 )
9092
91- with self .subTest ("ns_get_userns on invalid fd" ), self .assertRaisesRegex (
92- OSError , "25"
93+ with (
94+ self .subTest ("ns_get_userns on invalid fd" ),
95+ self .assertRaisesRegex (OSError , "25" ),
9396 ):
9497 ns_get_userns (temp_f .fileno ())
9598
96- with self .subTest ("ns_get_parent on invalid fd" ), self .assertRaisesRegex (
97- OSError , "25"
99+ with (
100+ self .subTest ("ns_get_parent on invalid fd" ),
101+ self .assertRaisesRegex (OSError , "25" ),
98102 ):
99103 ns_get_parent (temp_f .fileno ())
100104
101- with self .subTest ("ns_get_nstype on invalid fd" ), self .assertRaisesRegex (
102- OSError , "25"
105+ with (
106+ self .subTest ("ns_get_nstype on invalid fd" ),
107+ self .assertRaisesRegex (OSError , "25" ),
103108 ):
104109 ns_get_nstype (temp_f .fileno ())
105110
106- with self .subTest ("ns_get_owner_uid on invalid fd" ), self .assertRaisesRegex (
107- OSError , "25"
111+ with (
112+ self .subTest ("ns_get_owner_uid on invalid fd" ),
113+ self .assertRaisesRegex (OSError , "25" ),
108114 ):
109115 ns_get_owner_uid (temp_f .fileno ())
110116
@@ -149,11 +155,13 @@ def test_ns_get_functions(self) -> None:
149155 stat (child_userns_file_path ).st_ino ,
150156 )
151157
152- with open (child_userns_file_path ) as child_userns_file , open (
153- ns_get_parent (child_userns_file .fileno ())
154- ) as child_parent_ns_file , open (
155- ns_get_userns (child_userns_file .fileno ())
156- ) as child_userns_owner_userns_file :
158+ with (
159+ open (child_userns_file_path ) as child_userns_file ,
160+ open (ns_get_parent (child_userns_file .fileno ())) as child_parent_ns_file ,
161+ open (
162+ ns_get_userns (child_userns_file .fileno ())
163+ ) as child_userns_owner_userns_file ,
164+ ):
157165 self .assertEqual (
158166 ns_get_owner_uid (child_userns_file .fileno ()),
159167 getuid (),
0 commit comments