<div dir="ltr"><div><div><div><div>Hello,<br></div>I&#39;ve seen no answer concerning TDD, I&#39;ll try to give you one.<br></div>TDD means fast feedback, so tests must execute fast, and so you&#39;re looking for a design that&#39;s testable without reading your data in files.<br></div>In the TDD point of view, you&#39;ll have a code design where data are raw injected in the function you&#39;re testing and testing if data are well read is a non sense (for TDD only) <br></div>Hope it&#39;s clear.<br><div><div><br><br><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-09 11:29 GMT+02:00 David Palao <span dir="ltr">&lt;<a href="mailto:dpalao.python@gmail.com" target="_blank">dpalao.python@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
After playing around with systemfixtures, I don&#39;t find a way to make<br>
it work for my purposes.<br>
I&#39;m inclined to think that chroot is the answer to my question (thank<br>
you, Johan, for pointing it out from the beginning).<br>
<br>
As I  explained in my first post, I need a way to provide a fake<br>
filesystem to my functional tests. What I mean by functional tests is<br>
testing from the point of view of the user. What I do for that is: I<br>
call the executable from within my FTs, catch the output and compare<br>
it with the expected output.<br>
To call the executable I use subprocess.Popen. In principle it should<br>
be possible to provide a fake fs to it but, isn&#39;t it, at the end of<br>
the day, the same as creating a chroot jail?<br>
<br>
Unless there is an easy way to do what I need using systemfixtures (or<br>
fakefs), which I don&#39;t see, I think I will need to go to chroot (or<br>
docker). Any recommended tool to create a basic chroot jail with<br>
python in it that I can use to run my program and modify files in<br>
/proc?<br>
<br>
Thanks in advance.<br>
<br>
Best<br>
<div class="HOEnZb"><div class="h5"><br>
2017-01-24 15:08 GMT+01:00 Johan Olsen &lt;<a href="mailto:ulf.johan.olsen@gmail.com">ulf.johan.olsen@gmail.com</a>&gt;:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I would solve this by running my program in a chroot environment in some<br>
&gt; way. Chroot is used to change the apparent root directory for some running<br>
&gt; process and its children. You can then set up a mock /proc under e.g.<br>
&gt; /tmp/mock, and run your tests with chroot under pretense that /tmp/mock is<br>
&gt; your actual root folder. From python you can do this with os.chroot.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Johan Olsén<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 2017-01-24 14:51 GMT+01:00 David Palao &lt;<a href="mailto:dpalao.python@gmail.com">dpalao.python@gmail.com</a>&gt;:<br>
&gt;&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt; I am writing a program that does something based on information read<br>
&gt;&gt; from /proc (the target OS is linux). But I have some problems figuring<br>
&gt;&gt; out how to mock the /proc filesystem, or at least, some files in it.<br>
&gt;&gt;<br>
&gt;&gt; The rationale is that I want to change some files inside /proc to<br>
&gt;&gt; simulate different configurations of the host computer so that I can<br>
&gt;&gt; run my functional tests against those different configurations.<br>
&gt;&gt;<br>
&gt;&gt; I was thinking in using docker for this task. But<br>
&gt;&gt; 1) this is offtopic here :)<br>
&gt;&gt; and<br>
&gt;&gt; 2) I would like to learn what is the standard way to deal with such<br>
&gt;&gt; situations. If there is a &quot;standard way&quot; at all... I mean, what am I<br>
&gt;&gt; supposed to do from the point of view of TDD?<br>
&gt;&gt;<br>
&gt;&gt; I would appreciate if someone with experience in such problems could<br>
&gt;&gt; share some advice.<br>
&gt;&gt;<br>
&gt;&gt; Best,<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; David<br>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; testing-in-python mailing list<br>
&gt;&gt; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br>
&gt;&gt; <a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br>
&gt;<br>
&gt;<br>
<br>
______________________________<wbr>_________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br>
</div></div></blockquote></div><br></div>