Open mdklatt opened 8 months ago
Would it be possible to formulate the tests without adding the new
pyfakefs
dependency?
The Unix tests are the only ones that use pyfakefs
, so I can probably replace that with os.chroot
.
The Unix tests are the only ones that use
pyfakefs
, so I can probably replace that withos.chroot
.
That sounds a bit heavy-handed too... What if you just mock.patch
some of the relevant calls?
The Unix tests are the only ones that use
pyfakefs
, so I can probably replace that withos.chroot
.That sounds a bit heavy-handed too... What if you just
mock.patch
some of the relevant calls?
It turns out that os.chroot
will not work anyway because it requires root privileges. However, the _unix._get_localzone()
function takes an optional parameter specifically intended for testing, according to its docstring:
The parameter _root makes the function look for files like /etc/localtime beneath the _root directory. This is primarily used by the tests. In normal usage you call the function without parameters.
The get_localzone()
function is just a wrapper (for now...) around _get_localzone('/')
. I have a working commit that calls _get_localzone()
with a temporary test directory.
It looks like it would only be necessary to mock os.path.join()
in localtime._unix
if you still think that's better.
This is an update of https://github.com/python-babel/babel/pull/1006 that incorporates upstream fixes to previously-broken tests. It should pass all CI checks now.
This PR:
localtime
module (developed on macOS, test stub added for Windows)