File: test-version.py

package info (click to toggle)
pdf2djvu 0.9.18.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,248 kB
  • sloc: cpp: 6,873; sh: 4,327; xml: 4,193; python: 1,104; makefile: 715; perl: 17
file content (53 lines) | stat: -rw-r--r-- 1,667 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# encoding=UTF-8

# Copyright © 2015-2018 Jakub Wilk <jwilk@jwilk.net>
#
# This file is part of pdf2djvu.
#
# pdf2djvu is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# pdf2djvu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

import os
import re
import xml.etree.cElementTree as etree

from tools import (
    assert_equal,
    assert_fail,
    case,
)

here = os.path.dirname(__file__)
srcdir = os.path.join(here, os.pardir)

class test(case):

    def __init__(self):
        path = os.path.join(srcdir, 'doc', 'changelog')
        with open(path) as fp:
            line = fp.readline()
        self.changelog_version = line.split()[1].strip('()')

    def test_manpage(self):
        path = os.path.join(srcdir, 'doc', 'manpage.xml')
        for dummy_event, elem in etree.iterparse(path):
            if elem.tag == 'refmiscinfo' and elem.get('class') == 'version':
                assert_equal(elem.text, self.changelog_version)
                break
        else:
            assert_fail("missing <refmiscinfo class='version'>")

    def test_executable(self):
        r = self.pdf2djvu('--version')
        r.assert_(stdout=re.compile(r'^pdf2djvu [0-9.]+\r?\n', re.M), rc=0)
        exec_version = r.stdout.splitlines()[0]
        _, exec_version = exec_version.split()
        assert_equal(exec_version, self.changelog_version)

# vim:ts=4 sts=4 sw=4 et