示例#1
0
 def test_not_exist_font_config_option2(self):
     with self.assertRaises(RuntimeError):
         args = [
             '-f', '/font_is_not_exist', '-f', '/font_is_not_exist2',
             'input.diag'
         ]
         options = self.parser.parse(args)
         detectfont(options)
def not_exist_font_config_option_test():
    fontpath = get_fontpath()
    if os.path.exists(fontpath):
        args = ['-f', '/font_is_not_exist', '-f', fontpath, 'input.diag']
        options = blockdiag.command.BlockdiagOptions(blockdiag).parse(args)

        from blockdiag.utils.bootstrap import detectfont
        detectfont(options)
示例#3
0
def on_builder_inited(self):
    # show deprecated message
    if self.builder.config.rackdiag_tex_image_format:
        self.builder.warn(
            'rackdiag_tex_image_format is deprecated. Use rackdiag_latex_image_format.'
        )

    # initialize fontmap
    global fontmap

    try:
        fontmappath = self.builder.config.rackdiag_fontmap
        fontmap = FontMap(fontmappath)
    except:
        fontmap = FontMap(None)

    try:
        fontpath = self.builder.config.rackdiag_fontpath
        if isinstance(fontpath, string_types):
            fontpath = [fontpath]

        if fontpath:
            config = namedtuple('Config', 'font')(fontpath)
            fontpath = detectfont(config)
            fontmap.set_default_font(fontpath)
    except:
        pass
def on_builder_inited(self):
    # show deprecated message
    if self.builder.config.rackdiag_tex_image_format:
        self.builder.warn('rackdiag_tex_image_format is deprecated. Use rackdiag_latex_image_format.')

    # initialize fontmap
    global fontmap

    try:
        fontmappath = self.builder.config.rackdiag_fontmap
        fontmap = FontMap(fontmappath)
    except:
        fontmap = FontMap(None)

    try:
        fontpath = self.builder.config.rackdiag_fontpath
        if isinstance(fontpath, string_types):
            fontpath = [fontpath]

        if fontpath:
            config = namedtuple('Config', 'font')(fontpath)
            fontpath = detectfont(config)
            fontmap.set_default_font(fontpath)
    except:
        pass
示例#5
0
    def test_exist_font_config_option(self):
        try:
            tmp = tempfile.mkstemp()

            options = self.parser.parse(['-f', tmp[1], 'input.diag'])
            self.assertEqual(options.font, [tmp[1]])
            fontpath = detectfont(options)
            self.assertEqual(fontpath, tmp[1])
        finally:
            os.unlink(tmp[1])
示例#6
0
    def test_exist_font_config_option(self):
        try:
            fd, path = tempfile.mkstemp()
            os.close(fd)

            options = self.parser.parse(['-f', path, 'input.diag'])
            self.assertEqual(options.font, [path])
            fontpath = detectfont(options)
            self.assertEqual(fontpath, path)
        finally:
            os.unlink(path)
示例#7
0
    def test_exist_font_config_option(self):
        try:
            fd, path = tempfile.mkstemp()
            os.close(fd)

            options = self.parser.parse(['-f', path, 'input.diag'])
            self.assertEqual(options.font, [path])
            fontpath = detectfont(options)
            self.assertEqual(fontpath, path)
        finally:
            os.unlink(path)
示例#8
0
 def test_not_exist_fontmap_config(self):
     with self.assertRaises(RuntimeError):
         args = ['--fontmap', '/fontmap_is_not_exist', 'input.diag']
         options = self.parser.parse(args)
         fontpath = detectfont(options)
         self.assertTrue(fontpath)
示例#9
0
 def test_not_exist_fontmap_config(self):
     with self.assertRaises(RuntimeError):
         args = ['--fontmap', '/fontmap_is_not_exist', 'input.diag']
         options = self.parser.parse(args)
         fontpath = detectfont(options)
         self.assertTrue(fontpath)
示例#10
0
 def test_not_exist_font_config_option2(self):
     with self.assertRaises(RuntimeError):
         args = ['-f', '/font_is_not_exist',
                 '-f', '/font_is_not_exist2', 'input.diag']
         options = self.parser.parse(args)
         detectfont(options)
示例#11
0
def not_exist_font_config_option_test():
    args = ['-f', '/font_is_not_exist', '-f', FONTPATH, 'input.diag']
    options = blockdiag.command.BlockdiagOptions(blockdiag).parse(args)

    from blockdiag.utils.bootstrap import detectfont
    detectfont(options)
示例#12
0
def not_exist_font_config_option_test():
    args = ['-f', '/font_is_not_exist', '-f', FONTPATH, 'input.diag']
    options = blockdiag.command.BlockdiagOptions(blockdiag).parse(args)

    from blockdiag.utils.bootstrap import detectfont
    detectfont(options)
示例#13
0
 def test_auto_font_detection(self):
     options = self.parser.parse(['input.diag'])
     fontpath = detectfont(options)
     self.assertTrue(fontpath)