<div dir="ltr"><div><div><div><div>Hello,<br></div>I've seen no answer concerning TDD, I'll try to give you one.<br></div>TDD means fast feedback, so tests must execute fast, and so you're looking for a design that's testable without reading your data in files.<br></div>In the TDD point of view, you'll have a code design where data are raw injected in the function you're testing and testing if data are well read is a non sense (for TDD only) <br></div>Hope it'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"><<a href="mailto:dpalao.python@gmail.com" target="_blank">dpalao.python@gmail.com</a>></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't find a way to make<br>
it work for my purposes.<br>
I'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'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'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 <<a href="mailto:ulf.johan.olsen@gmail.com">ulf.johan.olsen@gmail.com</a>>:<br>
> Hello,<br>
><br>
> I would solve this by running my program in a chroot environment in some<br>
> way. Chroot is used to change the apparent root directory for some running<br>
> process and its children. You can then set up a mock /proc under e.g.<br>
> /tmp/mock, and run your tests with chroot under pretense that /tmp/mock is<br>
> your actual root folder. From python you can do this with os.chroot.<br>
><br>
> Regards,<br>
> Johan Olsén<br>
><br>
><br>
><br>
> 2017-01-24 14:51 GMT+01:00 David Palao <<a href="mailto:dpalao.python@gmail.com">dpalao.python@gmail.com</a>>:<br>
>><br>
>> Hello,<br>
>> I am writing a program that does something based on information read<br>
>> from /proc (the target OS is linux). But I have some problems figuring<br>
>> out how to mock the /proc filesystem, or at least, some files in it.<br>
>><br>
>> The rationale is that I want to change some files inside /proc to<br>
>> simulate different configurations of the host computer so that I can<br>
>> run my functional tests against those different configurations.<br>
>><br>
>> I was thinking in using docker for this task. But<br>
>> 1) this is offtopic here :)<br>
>> and<br>
>> 2) I would like to learn what is the standard way to deal with such<br>
>> situations. If there is a "standard way" at all... I mean, what am I<br>
>> supposed to do from the point of view of TDD?<br>
>><br>
>> I would appreciate if someone with experience in such problems could<br>
>> share some advice.<br>
>><br>
>> Best,<br>
>><br>
>><br>
>> David<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>
><br>
><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>