This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vajrasky
Recipients Claudiu.Popa, ezio.melotti, vajrasky
Date 2014-06-24.15:49:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403624976.63.0.799796555196.issue20069@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-06-24 15:49:36vajraskysetrecipients: + vajrasky, ezio.melotti, Claudiu.Popa
2014-06-24 15:49:36vajraskysetmessageid: <1403624976.63.0.799796555196.issue20069@psf.upfronthosting.co.za>
2014-06-24 15:49:36vajraskylinkissue20069 messages
2014-06-24 15:49:36vajraskycreate