You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some CI services (e.g. shippable) run code under the "root" user. Since commit c16a508 (PR #455, pyfakefs 3.5.4) pyfakefs uses the value from os.getuid() to emulate root permissions.
Some of my tests broke with that version as I tried to test for non-accessible files (using os.chmod(..., 0). Of course root can access all files.
Describe the solution you'd like
Ideally I'd like to tell pyfakefs to emulate a non-root user even though the Unix user might be "root". The setting should only be active for a given test (maybe bound to the "Patcher()" instance?).
I use the "Patcher" manually anyway so adding a parameter to the constructor or the .setUp() call (e.g. root_user=False) would be pretty easy.
Describe alternatives you've considered
I could do the same as some pyfakefs tests (e.g. FakeOsModuleTest) which means calling set_uid(1) manually. However that means additional boilerplate code (remembering the old value, using tearDown() to restore it, dealing with Windows).
class FakeOsModuleTest(FakeOsModuleTestBase):
def setUp(self):
super(FakeOsModuleTest, self).setUp()
# ...
set_uid(1)
The text was updated successfully, but these errors were encountered:
This makes sense. I'm a bit reluctant to add another argument to Patcher, but this is probably the best way. I will sleep on the matter, and if nothing else comes to mind, will add this.
Some CI services (e.g. shippable) run code under the "root" user. Since commit c16a508 (PR #455, pyfakefs 3.5.4) pyfakefs uses the value from
os.getuid()
to emulate root permissions.Some of my tests broke with that version as I tried to test for non-accessible files (using
os.chmod(..., 0)
. Of course root can access all files.Describe the solution you'd like
Ideally I'd like to tell pyfakefs to emulate a non-root user even though the Unix user might be "root". The setting should only be active for a given test (maybe bound to the "Patcher()" instance?).
I use the "Patcher" manually anyway so adding a parameter to the constructor or the
.setUp()
call (e.g.root_user=False
) would be pretty easy.Describe alternatives you've considered
I could do the same as some pyfakefs tests (e.g.
FakeOsModuleTest
) which means callingset_uid(1)
manually. However that means additional boilerplate code (remembering the old value, usingtearDown()
to restore it, dealing with Windows).The text was updated successfully, but these errors were encountered: