<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Hello,<br></div>
<div><br></div>
<div>My suggestion is that you checkout pyfakefs: <a href="https://github.com/jmcgeheeiv/pyfakefs">https://github.com/jmcgeheeiv/pyfakefs</a> | <a href="https://pypi.python.org/pypi/pyfakefs">https://pypi.python.org/pypi/pyfakefs</a><br></div>
<div><br></div>
<div>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.<br></div>
<div><br></div>
<div>HTH,<br></div>
<div><br></div>
<div>James<br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div>On Tue, 24 Jan 2017, at 02:08 PM, Johan Olsen wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div><div><div><div>Hello,<br></div>
</div>
<div>I would solve this by running my program in a chroot environment in some way. Chroot is used to <span>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.<br></span></div>
</div>
<div><span>Regards,</span><br></div>
</div>
<div><span>Johan Olsén<br></span></div>
<div><div><span><br>&nbsp;</span></div>
</div>
</div>
<div><div><br></div>
<div defang_data-gmailquote="yes"><div>2017-01-24 14:51 GMT+01:00 David Palao <span dir="ltr">&lt;<a href="mailto:dpalao.python@gmail.com">dpalao.python@gmail.com</a>&gt;</span>:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;"><div>Hello,<br></div>
<div> I am writing a program that does something based on information read<br></div>
<div> from /proc (the target OS is linux). But I have some problems figuring<br></div>
<div> out how to mock the /proc filesystem, or at least, some files in it.<br></div>
<div> <br></div>
<div> The rationale is that I want to change some files inside /proc to<br></div>
<div> simulate different configurations of the host computer so that I can<br></div>
<div> run my functional tests against those different configurations.<br></div>
<div> <br></div>
<div> I was thinking in using docker for this task. But<br></div>
<div> 1) this is offtopic here :)<br></div>
<div> and<br></div>
<div> 2) I would like to learn what is the standard way to deal with such<br></div>
<div> situations. If there is a "standard way" at all... I mean, what am I<br></div>
<div> supposed to do from the point of view of TDD?<br></div>
<div> <br></div>
<div> I would appreciate if someone with experience in such problems could<br></div>
<div> share some advice.<br></div>
<div> <br></div>
<div> Best,<br></div>
<div> <br></div>
<div> <br></div>
<div> David<br></div>
<div> <br></div>
<div> ______________________________<wbr>_________________<br></div>
<div> testing-in-python mailing list<br></div>
<div> <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br></div>
<div> <a href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br></div>
</blockquote></div>
</div>
<div><u>_______________________________________________</u><br></div>
<div>testing-in-python mailing list<br></div>
<div><a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br></div>
<div><a href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a><br></div>
</blockquote><div><br></div>
<div id="sig58208729"><div class="signature">--<br></div>
<div class="signature"><span>James Cooke<br>Backend software developer<br>CV PDF: <a href="http://jamescooke.info/docs/james_cooke_cv.pdf">http://jamescooke.info/docs/james_cooke_cv.pdf</a><br>Website: <a href="http://jamescooke.info/">http://jamescooke.info/</a></span></div>
</div>
<div><br></div>
</body>
</html>