def test_broken_file(self): with helper.Capturing() as output: mscxyz.execute(['--config-file', ini_file, 'meta', helper.get_tmpfile_path('broken.mscx')]) self.assertTrue('Error: XMLSyntaxError; message: Start tag expected, ' '\'<\' not found, line 1, column 1' in ' '.join(output))
def test_version(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(["--version"]) result = re.search("[^ ]* [^ ]*", output[0]) self.assertTrue(result)
def test_distribute_field_exception_unmatched(self): tmp = helper.get_tmpfile_path('simple.mscx') with helper.Capturing() as output: mscxyz.execute([ 'meta', '--distribute-field', 'vbox_title', '$metatag_work_title - $metatag_composer', tmp ]) self.assertTrue('UnmatchedFormatStringError' in output[-1])
def test_show_verbose_two(self): with helper.Capturing() as output: mscxyz.execute([ '-vv', 'meta', '--clean', 'all', helper.get_tmpfile_path('simple.mscx') ]) output = ' '.join(output) self.assertTrue('readonly_relpath_backup' in output)
def test_show_verbose_one(self): with helper.Capturing() as output: mscxyz.execute([ "-v", "meta", "--clean", "all", helper.get_tmpfile_path("simple.mscx") ]) output = " ".join(output) self.assertTrue("readonly_abspath" in output) self.assertFalse("readonly_relpath_backup" in output)
def test_broken_file(self): with helper.Capturing() as output: mscxyz.execute([ "--config-file", ini_file, "meta", helper.get_tmpfile_path("broken.mscx"), ]) self.assertTrue("Error: XMLSyntaxError; message: Start tag expected, " "'<' not found, line 1, column 1" in " ".join(output))
def test_show(self): with helper.Capturing() as output: mscxyz.execute([ '--config-file', ini_file, 'meta', '--clean', 'all', helper.get_tmpfile_path('meta-all-values.mscx') ]) self.assertEqual(output[0], '') self.assertTrue('meta-all-values.mscx' in ' '.join(output)) self.assertEqual(output[-1], 'vbox_title: “vbox_title” -> “”')
def test_show_simple_unverbose(self): with helper.Capturing() as output: mscxyz.execute([ '--config-file', ini_file, 'meta', '--clean', 'all', helper.get_tmpfile_path('simple.mscx') ]) self.assertEqual(output[0], '') self.assertTrue('simple.mscx' in ' '.join(output)) self.assertEqual(output[2], 'combined_composer: “Composer” -> “”') self.assertEqual(output[3], 'combined_title: “Title” -> “”') self.assertEqual(output[-1], 'vbox_title: “Title” -> “”')
def test_distribute_field_exception_unmatched(self): tmp = helper.get_tmpfile_path("simple.mscx") with helper.Capturing() as output: mscxyz.execute([ "meta", "--distribute-field", "vbox_title", "$metatag_work_title - $metatag_composer", tmp, ]) self.assertTrue("UnmatchedFormatStringError" in output[-1])
def test_show(self): with helper.Capturing() as output: mscxyz.execute([ "--config-file", ini_file, "meta", "--clean", "all", helper.get_tmpfile_path("meta-all-values.mscx"), ]) self.assertEqual(output[0], "") self.assertTrue("meta-all-values.mscx" in " ".join(output)) self.assertEqual(output[-1], "vbox_title: “vbox_title” -> “”")
def test_show_simple_unverbose(self): with helper.Capturing() as output: mscxyz.execute([ "--config-file", ini_file, "meta", "--clean", "all", helper.get_tmpfile_path("simple.mscx"), ]) self.assertEqual(output[0], "") self.assertTrue("simple.mscx" in " ".join(output)) self.assertEqual(output[2], "combined_composer: “Composer” -> “”") self.assertEqual(output[3], "combined_title: “Title” -> “”") self.assertEqual(output[-1], "vbox_title: “Title” -> “”")
def test_help_text(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(["-h"]) self.assertTrue("[-h]" in output[0])
def test_functions_in_rename(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(['rename', '--help']) self.assertTrue('%asciify{text}' in '\n'.join(output))
def test_help_short(self): with self.assertRaises(SystemExit) as cm: with helper.Capturing(): mscxyz.execute(['-h']) the_exception = cm.exception self.assertEqual(str(the_exception), '0')
def setUp(self): self.tmp = helper.get_tmpfile_path('simple.mscx') self.backup = self.tmp.replace('.mscx', '_bak.mscx') with helper.Capturing(): mscxyz.execute(['--backup', 'meta', self.tmp])
def _execute(args): with helper.Capturing() as output: mscxyz.execute(args) return output
def test_markdown(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(["help", "--markdown", "all"]) self.assertTrue("```" in output)
def test_functions_in_rename(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(["rename", "--help"]) self.assertTrue("%asciify{text}" in "\n".join(output))
def test_help_long(self): with self.assertRaises(SystemExit) as cm: with helper.Capturing(): mscxyz.execute(["--help"]) the_exception = cm.exception self.assertEqual(str(the_exception), "0")
def test_markdown(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(['help', '--markdown', 'all']) self.assertTrue('```' in output)
def test_batch(self, Meta): with helper.Capturing(): mscxyz.execute(["meta", helper.get_tmpdir_path("batch")]) self.assertEqual(Meta.call_count, 3)
def test_without_arguments(self): with self.assertRaises(SystemExit) as cm: with helper.Capturing("stderr"): mscxyz.execute() the_exception = cm.exception self.assertEqual(str(the_exception), "2")
def test_all(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(["help", "all"]) self.assertTrue(len(output) > 150)
def test_restructuredtext(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(["help", "--rst", "all"]) self.assertTrue(".. code-block:: text" in output)
def setUp(self): self.tmp = helper.get_tmpfile_path("simple.mscx") self.backup = self.tmp.replace(".mscx", "_bak.mscx") with helper.Capturing(): mscxyz.execute(["--backup", "meta", self.tmp])
def test_restructuredtext(self): with self.assertRaises(SystemExit): with helper.Capturing() as output: mscxyz.execute(['help', '--rst', 'all']) self.assertTrue('.. code-block:: text' in output)