def test_script_errors(self): """Verify that the run method catches errors correctly""" oldargv = sys.argv # non-existent templates are not caught until in 'run' sys.argv = ['zopeskel', 'no-template', 'my.package'] output = run() self.assertTrue('ERROR: No such template' in output) # calling the script with no arguments at all prints usage sys.argv = sys.argv[:1] output = run() self.assertTrue('Usage:' in output) sys.argv = oldargv
def test_script_features(self): """Verify that the help features of the script function correctly""" oldargv = sys.argv # --help produces the DESCRIPTION string sys.argv = ['zopeskel', '--help'] output = run() self.assertTrue(DESCRIPTION in output, '--help produces incorrect output: %s' % output) # --list produces a verbose list of all templates by category sys.argv = ['zopeskel', '--list'] output = run() cats = list_sorted_templates() catnames = cats.keys() templates = sum(cats.values(), []) tempnames = [t['name'] for t in templates] tempsums = [t['summary'] for t in templates] for cat in catnames: self.assertTrue(cat in output, '%s not in --list output' % cat) for tname in tempnames: self.assertTrue(tname in output, '%s not in --list output' % tname) for summary in tempsums: self.assertTrue(summary in output, '%s not in --list output' % summary) # --make-config-file produces a config file with headings for each # template sys.argv = ['zopeskel', '--make-config-file'] output = run() for theading in ['[' + name + ']' for name in tempnames]: self.assertTrue(theading in output, '%s does not appear in .zopeskel' % theading) # --version should output a version number. make sure it finds # something sys.argv = ['zopeskel', '--version'] output = run() self.assertFalse('unable' in output) sys.argv = oldargv