Vajrasky Kok added the comment:
Claudiu, I have revamped the test and put it in dedicated test class. Thanks!
1. About assertRaisesRegex, sorry, you're right. We can use it with "with"
statement. Prior to this, I used it like this:
with self.assertRaisesRegex(PermissionError,
"Operation not permitted"):
bla
bla
Then I realized I have to use it like this:
with self.assertRaisesRegex(PermissionError,
"Operation not permitted") as _:
bla
bla
2. About this code, it is deliberate:
+ with self.assertRaises(PermissionError) as cx:
+ os.chown(support.TESTFN, uid_1, gid)
+ os.chown(support.TESTFN, uid_2, gid)
Normal user does not have permission to use chown to change the user of the
file. Basically, I need to find the other user other than the user of
support.TESTFN. By using chown with two users, it will be guaranteed the case
will be tried.
There is other way though, iterating all users and check whether the user is
not the owner of support.TESTFN or not. If you object it, I can use this way.
----------
Added file: http://bugs.python.org/file35771/add_unit_test_os_chown_v4.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20069>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com