[TIP] mocking a file in /proc
me at jamescooke.info
Tue Jan 24 06:15:12 PST 2017
My suggestion is that you checkout pyfakefs:
Although I've not used it for a year or so, I've had previous good
experience using it for mocking out entire file systems, and I think you
should be able to create the files you want under `/proc` for your test
suite with no problem.
On Tue, 24 Jan 2017, at 02:08 PM, Johan Olsen wrote:
> I would solve this by running my program in a chroot environment in
> some way. Chroot is used to change the apparent root directory for
> some running process and its children. You can then set up a mock
> /proc under e.g. /tmp/mock, and run your tests with chroot under
> pretense that /tmp/mock is your actual root folder. From python you
> can do this with os.chroot.
> Johan Olsén
> 2017-01-24 14:51 GMT+01:00 David Palao <dpalao.python at gmail.com>:
>> I am writing a program that does something based on information read
>> from /proc (the target OS is linux). But I have some problems
>> out how to mock the /proc filesystem, or at least, some files in it.
>> The rationale is that I want to change some files inside /proc to
>> simulate different configurations of the host computer so that I can
>> run my functional tests against those different configurations.
>> I was thinking in using docker for this task. But
>> 1) this is offtopic here :)
>> 2) I would like to learn what is the standard way to deal with such
>> situations. If there is a "standard way" at all... I mean, what am I
>> supposed to do from the point of view of TDD?
>> I would appreciate if someone with experience in such problems could
>> share some advice.
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
James Cooke Backend software developer CV PDF:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python