Esempio n. 1
0
 def test_lines_text_document(self):
     """Verify a text report can be created from a document."""
     path = os.path.join(FILES, 'report.txt')
     expected = open(path).read()
     lines = report.lines(self.document, '.txt', ignored=self.work.ignored)
     text = ''.join(line + '\n' for line in lines)
     if ASSERT_CONTENTS:
         self.assertEqual(expected, text)
     with open(path, 'w') as outfile:
         outfile.write(text)
Esempio n. 2
0
 def test_lines_text_item_no_ref(self):
     """Verify a text report can be created without checking references."""
     self.item.ref = 'abc123'
     self.item.heading = False
     _check_ref = bool(settings.CHECK_REF)
     try:
         settings.CHECK_REF = False
         lines = report.lines(self.item, '.txt', ignored=self.work.ignored)
         text = ''.join(line + '\n' for line in lines)
     finally:
         settings.CHECK_REF = _check_ref
     self.assertIn("Reference: 'abc123'", text)
Esempio n. 3
0
def _run_publish(args, cwd, _):
    """Process arguments and run the `demo report` subcommand.

    @param args: Namespace of CLI arguments
    @param cwd: current working directory
    @param err: function to call for CLI errors

    """
    try:
        tree = build(cwd, root=args.project)
        document = tree.find_document(args.prefix)
    except DemoError as error:
        logging.error(error)
        return False
    else:

        kwargs = {'ignored': tree.vcs.ignored}
        if args.width:
            kwargs['width'] = args.width

        if args.path:
            ext = os.path.splitext(args.path)[-1]
        if args.markdown:
            ext = '.md'
        elif args.html:
            ext = '.html'
        elif not args.path:
            ext = '.txt'

        if args.path:
            print("publishing {} to {}...".format(document, args.path))
            report.publish(document, args.path, ext, **kwargs)
        else:
            for line in report.lines(document, ext, **kwargs):
                print(line)

        return True
Esempio n. 4
0
 def test_lines_text_item(self):
     """Verify a text report can be created from an item."""
     expected = "1.0     Heading\n\n"
     lines = report.lines(self.item, '.txt', ignored=self.work.ignored)
     text = ''.join(line + '\n' for line in lines)
     self.assertEqual(expected, text)
Esempio n. 5
0
 def test_lines_unknown(self):
     """Verify iterating an unknown format raises."""
     gen = report.lines(self.document, '.a')
     self.assertRaises(DemoError, list, gen)
Esempio n. 6
0
 def test_lines_html_item(self):
     """Verify an HTML report can be created from an item."""
     expected = "<h1>1.0 Heading</h1>\n"
     lines = report.lines(self.item, '.html', ignored=self.work.ignored)
     text = ''.join(line + '\n' for line in lines)
     self.assertEqual(expected, text)