File: test.py

package info (click to toggle)
python-markdown2 2.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,492 kB
  • sloc: python: 6,201; perl: 1,493; php: 865; makefile: 37
file content (60 lines) | stat: -rwxr-xr-x 1,823 bytes parent folder | download
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
54
55
56
57
58
59
60
#!/usr/bin/env python
# Copyright (c) 2007-2008 ActiveState Software Inc.
# License: MIT (http://www.opensource.org/licenses/mit-license.php)

"""The markdown2 test suite entry point."""

import importlib
import os
from os.path import join, abspath, dirname
import sys
import logging
import testlib

log = logging.getLogger("test")
testdir_from_ns = {
    None: os.curdir,
}

def setup():
    top_dir = dirname(dirname(abspath(__file__)))
    lib_dir = join(top_dir, "lib")
    sys.path.insert(0, lib_dir)

    # Attempt to get 'pygments' on the import path.
    try:
        # If already have it, use that one.
        import pygments  # noqa
    except ImportError:
        pygments_dir = join(top_dir, "deps", "pygments")
        sys.path.insert(0, pygments_dir + "3")

if __name__ == "__main__":
    logging.basicConfig()

    setup()
    default_tags = []
    warnings = []
    for extra_lib in ('pygments', 'wavedrom', 'latex2mathml'):
        try:
            mod = importlib.import_module(extra_lib)
        except ImportError:
            warnings.append("skipping {} tests ('{}' module not found)".format(extra_lib, extra_lib))
            default_tags.append("-%s" % extra_lib)
        else:
            if extra_lib == 'pygments':
                version = tuple(int(i) for i in mod.__version__.split('.')[:3])
                if version >= (2, 14, 0):
                    tag = "pygments<2.14"
                else:
                    tag = "pygments>=2.14"
                warnings.append("skipping {} tests (pygments {} found)".format(tag, mod.__version__))
                default_tags.append("-%s" % tag)

    retval = testlib.harness(testdir_from_ns=testdir_from_ns,
                             default_tags=default_tags)

    for warning in warnings:
        log.warning(warning)

    sys.exit(retval)