Tests in multiple directories need to be run from within their own directory

303 views
Skip to first unread message

Jay Doane

unread,
Oct 13, 2010, 7:09:14 PM10/13/10
to nose-users
I have been using nose from within a python script to execute tests in
a different directory. Somewhat simplified:

import nose

def main():
testfiles = 'install_plan.py, json_metadata_utils.py, library.py'
where = '../build_output/fc/foobar.app/Contents/Frameworks/
install'
argv=['--verbosity=0', '--with-doctest', '--where=%s'%where, '--
tests=%s'%testfiles]
nose.main(argv=argv)

if __name__ == '__main__':
main()

And this works fine.

However, now I need to add another test file, but it is in a different
directory than "where" above. I've tried several things to no avail,
and the problem always seems to stem from the need to have multiple
different working directories at various times during test execution.

Also, I don't want to break the testing up into multiple nose runs
(ahem) because I'm using nose to aggregate the results into a single
xml file.

Can someone suggest options to solve this problem?

Thanks,
Jay

Tim Hatch

unread,
Oct 13, 2010, 7:20:59 PM10/13/10
to nose-...@googlegroups.com
> However, now I need to add another test file, but it is in a different
> directory than "where" above. I've tried several things to no avail,
> and the problem always seems to stem from the need to have multiple
> different working directories at various times during test execution.

Is it possible to specify a parent of the two different wheres as the
real where, then rely on the test-detection logic to only find the right
files? Is the second where relying on its files being in a certain
package, or could you use a symlink to put it inside the first?

Tim

Jay Doane

unread,
Oct 14, 2010, 1:25:35 PM10/14/10
to nose-...@googlegroups.com
On Oct 13, 2010, at 4:20 PM, Tim Hatch wrote:

>> However, now I need to add another test file, but it is in a
>> different
>> directory than "where" above. I've tried several things to no avail,
>> and the problem always seems to stem from the need to have multiple
>> different working directories at various times during test execution.
>
> Is it possible to specify a parent of the two different wheres as the
> real where, then rely on the test-detection logic to only find the
> right
> files?

I need to be able to specify exactly the directories/files nose should
be looking in, and not use test detection.

Ideally, I would be able to pass nose a list of (working_dir,
testfile) pairs to be run.

Would that mean writing a new TestLoader? Or does the current
assumption of a single working directory pervade the entirety of nose?

> Is the second where relying on its files being in a certain
> package, or could you use a symlink to put it inside the first?

As it's currently written, the new test file would need to be altered
if it gets moved/symlinked.

It may be that I need to make it a bit more adaptable, however.

Thanks for the response!

Jay

Reply all
Reply to author
Forward
0 new messages