[TIP] Multiplatform testing with nose

Yoni Tsafir yonix85 at gmail.com
Tue Feb 15 04:32:36 PST 2011


Thanks! I'll try the nose-users list - didn't know of it.
Tried to run with '-i tests' BTW, didn't do the trick.

On Tue, Feb 15, 2011 at 11:10 AM, holger krekel <holger at merlinux.eu> wrote:

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


More information about the testing-in-python mailing list