Warn if dependencies can't be tested
This commit is contained in:
parent
6054a35c5a
commit
33e669b3fa
@ -21,6 +21,10 @@ sys.path[0] = os.getcwd()
|
|||||||
# find all of the planet test modules
|
# find all of the planet test modules
|
||||||
modules = map(fullmodname, glob.glob(os.path.join('tests', 'test_*.py')))
|
modules = map(fullmodname, glob.glob(os.path.join('tests', 'test_*.py')))
|
||||||
|
|
||||||
|
# enable warnings
|
||||||
|
import planet
|
||||||
|
planet.getLogger("WARNING")
|
||||||
|
|
||||||
# load all of the tests into a suite
|
# load all of the tests into a suite
|
||||||
suite = unittest.TestLoader().loadTestsFromNames(modules)
|
suite = unittest.TestLoader().loadTestsFromNames(modules)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import unittest, os, shutil
|
import unittest, os, shutil
|
||||||
from planet import config, splice
|
from planet import config, splice, logger
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
|
||||||
workdir = 'tests/work/apply'
|
workdir = 'tests/work/apply'
|
||||||
@ -62,3 +62,26 @@ class ApplyTest(unittest.TestCase):
|
|||||||
self.assertTrue(html.find('<h1>test planet</h1>')>=0)
|
self.assertTrue(html.find('<h1>test planet</h1>')>=0)
|
||||||
self.assertTrue(html.find(
|
self.assertTrue(html.find(
|
||||||
'<h4><a href="http://example.com/2">Venus</a></h4>')>=0)
|
'<h4><a href="http://example.com/2">Venus</a></h4>')>=0)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import libxml2
|
||||||
|
except ImportError:
|
||||||
|
|
||||||
|
try:
|
||||||
|
import win32pipe
|
||||||
|
(stdin,stdout) = win32pipe.popen4('xsltproc -V', 't')
|
||||||
|
stdin.close()
|
||||||
|
stdout.read()
|
||||||
|
try:
|
||||||
|
exitcode = stdout.close()
|
||||||
|
except IOError:
|
||||||
|
exitcode = -1
|
||||||
|
except:
|
||||||
|
import commands
|
||||||
|
(exitstatus,output) = commands.getstatusoutput('xsltproc -V')
|
||||||
|
exitcode = ((exitstatus>>8) & 0xFF)
|
||||||
|
|
||||||
|
if exitcode:
|
||||||
|
logger.warn("xsltproc is not available => can't test XSLT templates")
|
||||||
|
for method in dir(ApplyTest):
|
||||||
|
if method.startswith('test_'): delattr(ApplyTest,method)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import unittest, xml.dom.minidom
|
import unittest, xml.dom.minidom
|
||||||
from planet import shell, config
|
from planet import shell, config, logger
|
||||||
|
|
||||||
class FilterTests(unittest.TestCase):
|
class FilterTests(unittest.TestCase):
|
||||||
|
|
||||||
@ -80,12 +80,10 @@ try:
|
|||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
sed=Popen(['sed','--version'],stdout=PIPE,stderr=PIPE)
|
sed=Popen(['sed','--version'],stdout=PIPE,stderr=PIPE)
|
||||||
sed.communicate()
|
sed.communicate()
|
||||||
if sed.returncode != 0: raise Exception
|
if sed.returncode != 0:
|
||||||
except Exception, expr:
|
logger.warn("sed is not available => can't test stripAd_yahoo")
|
||||||
# sed is not available
|
del FilterTests.test_stripAd_yahoo
|
||||||
del FilterTests.test_stripAd_yahoo
|
except ImportError:
|
||||||
|
logger.warn("Popen is not available => can't test filters")
|
||||||
if isinstance(expr, ImportError):
|
for method in dir(FilterTests):
|
||||||
# Popen is not available
|
if method.startswith('test_'): delattr(FilterTests,method)
|
||||||
for method in dir(FilterTests):
|
|
||||||
if method.startswith('test_'): delattr(FilterTests,method)
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import unittest, os, shutil
|
import unittest, os, shutil
|
||||||
from planet.foaf import foaf2config
|
from planet.foaf import foaf2config
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
from planet import config
|
from planet import config, logger
|
||||||
|
|
||||||
workdir = 'tests/work/config/cache'
|
workdir = 'tests/work/config/cache'
|
||||||
|
|
||||||
@ -119,6 +119,7 @@ class FoafTest(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
import RDF
|
import RDF
|
||||||
except:
|
except:
|
||||||
|
logger.warn("Redland RDF is not available => can't test FOAF reading lists")
|
||||||
for key in FoafTest.__dict__.keys():
|
for key in FoafTest.__dict__.keys():
|
||||||
if key.startswith('test_'): delattr(FoafTest, key)
|
if key.startswith('test_'): delattr(FoafTest, key)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user