Message46934
Logged In: YES
user_id=80475
After more thought, I think decorators offer a cleaner, more
complete solution without further complicating the unittest
module.
def rootonly(f):
"Decorator to skip tests that require root access"
if os.geteuid() == 0:
return f
return lambda self: 0
@rootonly
def testReadingAsRoot(self):
. . .
Note the rootonly() decorator need only be defined once
instead of writing a full self.skipIf(condition) inside
every test. Also, it appears prior to the definition rather
than inside. The approach is more flexible than the
original proposal though it does lack a reporting mechanism. |
|
Date |
User |
Action |
Args |
2007-08-23 15:39:54 | admin | link | issue1034053 messages |
2007-08-23 15:39:54 | admin | create | |
|