def test_forced_description(self): """The description of the template is provided as parameter """ # With a template which config file has no description descr = "This template is wonderful" reg = register_template('templates/empty', description=descr) self.assertTrue(descr in reg.description) # With a config file that has another description reg = register_template('templates/config_description', description=descr) self.assertTrue(descr in reg.description) return
def test_registered_path(self): """The registered template path is OK """ this_directory = os.path.dirname(__file__) expect = os.path.join(this_directory, 'templates/empty') reg = register_template('templates/empty') self.assertEqual(reg.directory, expect) return
def test_config_description(self): """The description of the template is in the config file """ reg = register_template('templates/config_description') self.assertTrue("The description is in the config file" in reg.description) return
def test_bob_template_wo_description(self): """This is a mr.bob template folder but its config has no description """ reg = register_template('templates/empty') self.assertTrue("No description available" in reg.description) return
# Custom logger LOG = logging.getLogger(name=__name__) if sys.version_info < (2, 7): class NullHandler(logging.Handler): """Copied from Python 2.7 to avoid getting `No handlers could be found for logger "xxx"` http://bugs.python.org/issue16539 """ def handle(self, record): pass def emit(self, record): pass def createLock(self): self.lock = None else: from logging import NullHandler LOG.addHandler(NullHandler()) # PEP 0396 style version marker try: __version__ = pkg_resources.get_distribution(__name__).version except: LOG.warning("Could not get the package version from pkg_resources") __version__ = 'unknown' # Templates registration nspackage = register_template('nspackage') buildout = register_template('buildout') mybobtemplate = register_template('mybobtemplate')