Test programs assumptions

Martin Schulze joey at infodrom.org
Thu Mar 18 18:08:41 CET 2004


Moin!

Bernhard Herzog wrote:
> > Does this imply that other tests outside the test/ directory
> > (i.e. ../Extension/**/test/test*.py) will be executed from within the
> > test/ directory if they get included in the normal test suite?
> 
> If you run them with test/runtests.py (and expect the tests in test/ to
> work): yes.

Thought that was the long-term plan. :)

> > As soon as you want to import other modules, load files, run external
> > programs you have to make assumptions on the paths, which is why I
> > ask, so I know how the tools are supposed to work.
> 
> Well, __file__ will give you the name of the current module, so you can
> use that to figure out where files are if you know the location relative
> to the module's file.  E.g. a file "foo" in the same directory is
> usually os.path.join(os.path.dirname(__file__), "foo")

That's a good idea, will implement it this way.  Thanks a lot!

> That's the way it currently is for some of the tests, which is more or
> less by accident.  I wouldn't say that they are supposed to be run from
> there.  It's the only way it currently works if you want to be able to
> run all the tests but that really is a bug that ought to be fixed.

I wish not to introduce more such "accidents", hence my questions.

> >> See test/postgissupport.py for this might be used.  If you raise
> >> SkipTest you need to use support.run_tests instead of unittest.main so
> >> that it is handled as intended (with the normal unittest it would be
> >> flagged as an error).

Hmm, I seem to be unable to import test.support in order to import
SkipTest and stuff.  There's no __init__.py in the test directory but
even creating it doesn't seem to help.  Looks like I'm a bit lost
now.

I'd be glad if you could give me a hand with incorporating this into
Extensions/wms/test/test_ogclib.py.

> > Which leads me back to my initial question, which directory to assume
> > besides the one the test is stored in, since support.py is either
> > test.support, support or ../../../test/support.
> 
> Good question.  I must admit that I'm not sure exactly how we need to
> extend the test suite and its support code to handle tests outside of
> test/.  For the svgexport tests I only did the minimum to make them run
> as part of the whole test suite when run via test/runtests.py.

Well, in the long-term I'd suggest to include all the various test
suites into the main one if the goal is to place the test suites next
to the code it tests.  You'll have to decide one day, not necessarily
today, though.

> The easiest way for you to continue is probably this:
> 
> create your own support module in Extensions/wms/test and put the some

done

> code there that is run only once to add some directories to sys.path,

done

> like the Thuban main directory and test so that you can import Thuban

added

> and the test support modules.  You can't call it support.py though

failed, see above, I'm a bit clueless with that problem.

> because then it would shadow the support module from test/.

Ack.

Regards,

	Joey

-- 
The MS-DOS filesystem is nice for removable media.  -- H. Peter Anvin




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)