Test programs assumptions
Bernhard Herzog
bh at intevation.de
Fri Mar 19 16:51:46 CET 2004
Martin Schulze <joey at infodrom.org> writes:
> ogclib contains class WMSClient
>
> [..]
> from ogclib import WMSClient
>
> class TestWMSClient (unittest.TestCase, WMSClient)
> def...
> def
> skip_if_no_ogclib()
> [..]
>
> This won't work since if the class TestWMSClient cannot be created
> since WMSClient is not available.
>
> Any idea how to solve this dilemma?
Is it really necessary that TestWMSClient is a subclass of WMSClient?
You could do something like this instead:
_ogc_import_error = ""
try:
from ogclib.WMSClient import WMSClient
except ImportError, e:
_ogc_import_error = str(e)
def skip_if_no_ogclib():
if _ogc_import_error:
raise support.SkipTest(_ogc_import_error)
class TestWMSClient(unittest.TestCase):
def setUp(self):
skip_if_no_ogclib()
def test_foo(self):
client = WMSClient()
...
WMSClient is a mix-in class and therfore is usually used by deriving a
class from it, so it might be a bit cleaner to derive a special client
class, like it's done in the tests in PyOGCLib itself.
Bernhard
--
Intevation GmbH http://intevation.de/
Skencil http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)