[TIP] mocking a file in /proc

Johan Olsen ulf.johan.olsen at gmail.com
Tue Jan 24 06:08:13 PST 2017


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>:

> Hello,
> I am writing a program that does something based on information read
> from /proc (the target OS is linux). But I have some problems figuring
> 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 :)
> and
> 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.
> Best,
> David
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170124/cb1feeca/attachment.html>

More information about the testing-in-python mailing list