Пример #1
0
 def test_custom_pretty_printer(self):
     """Test pretty printing of deb822 objects and parsed relationships."""
     printer = CustomPrettyPrinter()
     # Test pretty printing of debian.deb822.Deb822 objects.
     deb822_object = deb822_from_string('''
         Package: pretty-printed-control-fields
         Version: 1.0
         Architecture: all
     ''')
     formatted_object = printer.pformat(deb822_object)
     assert normalize_repr_output(
         formatted_object) == normalize_repr_output('''
         {'Architecture': u'all',
          'Package': u'pretty-printed-control-fields',
          'Version': u'1.0'}
     ''')
     # Test pretty printing of RelationshipSet objects.
     relationship_set = parse_depends(
         'python-deb-pkg-tools, python-pip, python-pip-accel')
     formatted_object = printer.pformat(relationship_set)
     assert normalize_repr_output(
         formatted_object) == normalize_repr_output('''
         RelationshipSet(Relationship(name='python-deb-pkg-tools', architectures=()),
                         Relationship(name='python-pip', architectures=()),
                         Relationship(name='python-pip-accel', architectures=()))
     ''')
Пример #2
0
 def test_custom_pretty_printer(self):
     printer = CustomPrettyPrinter()
     # Test pretty printing of debian.deb822.Deb822 objects.
     self.assertEqual(
         remove_unicode_prefixes(
             printer.pformat(
                 deb822_from_string('''
         Package: pretty-printed-control-fields
         Version: 1.0
         Architecture: all
     '''))),
         remove_unicode_prefixes(
             dedent('''
         {'Architecture': u'all',
          'Package': u'pretty-printed-control-fields',
          'Version': u'1.0'}
     ''')))
     # Test pretty printing of RelationshipSet objects.
     depends_line = 'python-deb-pkg-tools, python-pip, python-pip-accel'
     self.assertEqual(
         printer.pformat(parse_depends(depends_line)),
         dedent('''
         RelationshipSet(Relationship(name='python-deb-pkg-tools'),
                         Relationship(name='python-pip'),
                         Relationship(name='python-pip-accel'))
     '''))
Пример #3
0
 def test_custom_pretty_printer(self):
     printer = CustomPrettyPrinter()
     # Test pretty printing of debian.deb822.Deb822 objects.
     self.assertEqual(remove_unicode_prefixes(printer.pformat(deb822_from_string('''
         Package: pretty-printed-control-fields
         Version: 1.0
         Architecture: all
     '''))), remove_unicode_prefixes(dedent('''
         {'Architecture': u'all',
          'Package': u'pretty-printed-control-fields',
          'Version': u'1.0'}
     ''')))
     # Test pretty printing of RelationshipSet objects.
     depends_line = 'python-deb-pkg-tools, python-pip, python-pip-accel'
     self.assertEqual(printer.pformat(parse_depends(depends_line)), dedent('''
         RelationshipSet(Relationship(name='python-deb-pkg-tools'),
                         Relationship(name='python-pip'),
                         Relationship(name='python-pip-accel'))
     '''))
Пример #4
0
 def test_custom_pretty_printer(self):
     """Test pretty printing of deb822 objects and parsed relationships."""
     printer = CustomPrettyPrinter()
     # Test pretty printing of debian.deb822.Deb822 objects.
     deb822_object = deb822_from_string('''
         Package: pretty-printed-control-fields
         Version: 1.0
         Architecture: all
     ''')
     formatted_object = printer.pformat(deb822_object)
     assert normalize_repr_output(formatted_object) == normalize_repr_output('''
         {'Architecture': u'all',
          'Package': u'pretty-printed-control-fields',
          'Version': u'1.0'}
     ''')
     # Test pretty printing of RelationshipSet objects.
     relationship_set = parse_depends('python-deb-pkg-tools, python-pip, python-pip-accel')
     formatted_object = printer.pformat(relationship_set)
     assert normalize_repr_output(formatted_object) == normalize_repr_output('''
         RelationshipSet(Relationship(name='python-deb-pkg-tools', architectures=()),
                         Relationship(name='python-pip', architectures=()),
                         Relationship(name='python-pip-accel', architectures=()))
     ''')
def testfile(filename, verbose=False):
    logger.info("Checking %s", format_path(filename))
    printer = CustomPrettyPrinter()
    filename = os.path.abspath(filename)
    cwd_save = os.getcwd()
    os.chdir(SAMPLES_DIRECTORY)
    results = doctest.testfile(filename=filename,
                               module_relative=False,
                               globs=dict(repr=printer.pformat),
                               optionflags=doctest.NORMALIZE_WHITESPACE,
                               verbose=verbose)
    if results.attempted > 0:
        if results.failed == 0:
            logger.info("Evaluated %i doctests, all passed!", results.attempted)
        else:
            logger.error("Evaluated %i doctests, %i failed!", results.attempted, results.failed)
    os.chdir(cwd_save)
    return results.failed