<div dir="ltr">Thanks! I&#39;ll try the nose-users list - didn&#39;t know of it.<div>Tried to run with &#39;-i tests&#39; BTW, didn&#39;t do the trick.<br><div><br><div class="gmail_quote">On Tue, Feb 15, 2011 at 11:10 AM, holger krekel <span dir="ltr">&lt;<a href="mailto:holger@merlinux.eu">holger@merlinux.eu</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Tue, Feb 15, 2011 at 10:22 +0200, Yoni Tsafir wrote:<br>
&gt; &gt; Yoni,<br>
&gt; &gt;<br>
&gt; &gt; could you maybe give some precise example directory layout instead<br>
&gt; &gt; of describing it in words?<br>
&gt; &gt;<br>
&gt;<br>
&gt; Well, its something like this:<br>
&gt; myproject/<br>
&gt; - contains non platform-specific code (in root and in other subdirectories)<br>
&gt; myproject/platform/&lt;platform_name&gt;/**<br>
&gt; - contains platform specific code for each platform<br>
<br>
</div>And your tests are in myprojects/test*/ and myproject/platform/platform_name/test*/<br>
directories?<br>
<br>
If so, i am sure you can solve it with nose but someone else needs to tell you<br>
how.  I could only tell you a solution for py.test.<br>
<br>
You might want to mail nose-users via<br>
<a href="http://groups.google.com/group/nose-users?hl=en" target="_blank">http://groups.google.com/group/nose-users?hl=en</a><br>
<br>
hth,<br>
<font color="#888888">holger<br>
</font><div><div></div><div class="h5"><br>
&gt; &gt;<br>
&gt; &gt; Besides, it&#39;s always good to avoid code in __init__.py<br>
&gt; &gt; files including imports.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; I agree with this in general. This might just be what I&#39;ll have to do for<br>
&gt; our code...<br>
&gt; Won&#39;t be very easy though... :)<br>
&gt;<br>
&gt;<br>
&gt; &gt; best,<br>
&gt; &gt; holger<br>
&gt; &gt;<br>
&gt; &gt; On Mon, Feb 14, 2011 at 19:14 +0200, Yoni Tsafir wrote:<br>
&gt; &gt; &gt; OK,<br>
&gt; &gt; &gt; So I know a few weeks ago there was a multiplatform related question, but<br>
&gt; &gt; &gt; mine is a bit different.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I&#39;m working on a project that has platform specific code in its working<br>
&gt; &gt; &gt; tree.<br>
&gt; &gt; &gt; No matter what are the reasons, but currently in the same project tree<br>
&gt; &gt; there<br>
&gt; &gt; &gt; is platform specific code for several platforms side by side, and it<br>
&gt; &gt; &gt; currently can&#39;t be separated to different trees.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Now, about the unit-tests: pretty simple, each unit-test that can run<br>
&gt; &gt; only<br>
&gt; &gt; &gt; on a specific platform, raises a SkipTest in case you try running it on a<br>
&gt; &gt; &gt; different one (similar to what was suggested here a few weeks back).<br>
&gt; &gt; &gt; Also, notice that some unit-tests may be in a platform specific package,<br>
&gt; &gt; but<br>
&gt; &gt; &gt; can actually run on all packages (because of mocks).<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Great.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Now,<br>
&gt; &gt; &gt; I want to be able to run all tests in my project with nose by running<br>
&gt; &gt; &gt; nosetests recursively on the root directory.<br>
&gt; &gt; &gt; What&#39;s the problem with that?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; The problem is that some of my __init__.py of the windows specific code,<br>
&gt; &gt; &gt; imports win32api, which exists only in windows.<br>
&gt; &gt; &gt; Now from what I could understand, when nose is given a directory rather<br>
&gt; &gt; than<br>
&gt; &gt; &gt; a list of tests, it tries finding tests in all the packages recursively,<br>
&gt; &gt; and<br>
&gt; &gt; &gt; in the process it actually imports all __init__.py of modules, including<br>
&gt; &gt; the<br>
&gt; &gt; &gt; ones that are trying to import other platform specific stuff.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; This is a problem, because there are no tests to skip here, and I end up<br>
&gt; &gt; &gt; getting an Error in my test-suite that isn&#39;t actually connected to a<br>
&gt; &gt; test.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Now, the way I see handling this right now, is avoiding importing stuff<br>
&gt; &gt; in<br>
&gt; &gt; &gt; __init__.py of packages, and either insert it into the function<br>
&gt; &gt; definitions,<br>
&gt; &gt; &gt; or to other .py files that are imported only explicitly and not from<br>
&gt; &gt; other<br>
&gt; &gt; &gt; __init__.py<br>
&gt; &gt; &gt; I must say I&#39;m not really crazy about this solution.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Other solutions I thought of is to separate my code to different working<br>
&gt; &gt; &gt; trees and run on them (which is a big problem currently),<br>
&gt; &gt; &gt; Or using something like --exclude=windows in nose, but this is bad<br>
&gt; &gt; because<br>
&gt; &gt; &gt; under windows there are unit tests that can be ran on any platform<br>
&gt; &gt; (because<br>
&gt; &gt; &gt; of mocks).<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I was wondering if any of you can think of a better way to solve this<br>
&gt; &gt; &gt; annoying problem.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks!<br>
&gt; &gt; &gt; Yoni.<br>
&gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; testing-in-python mailing list<br>
&gt; &gt; &gt; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
&gt; &gt; &gt; <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt;<br>
<br>
</div></div>--<br>
</blockquote></div><br></div></div></div>