File: run_tests.py

package info (click to toggle)
pymdown-extensions 10.13-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,104 kB
  • sloc: python: 60,117; javascript: 846; sh: 8; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,365 bytes parent folder | download | duplicates (3)
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
"""Run the unittests or update unitest compare files."""
import argparse
from tests import test_syntax
from tests import test_targeted
import sys
import os


def main():
    """Main function."""

    parser = argparse.ArgumentParser(prog='run_tests', description='Run extension tests.')
    # Flag arguments
    parser.add_argument('--update', '-u', action='store_true', default=False, help="Update expected HTML output.")
    parser.add_argument(
        '--test-target', '-t', nargs=1, action='store', default="", choices=['syntax', 'targeted'],
        help="Test specific enivronment."
    )
    parser.add_argument(
        '--file', '-f', nargs=1, action='store', default="", help="Test or update specific test."
    )
    args = parser.parse_args()
    sys.argv = sys.argv[0:1]

    if args.file:
        abs_path = os.path.abspath(args.file[0])
        if os.path.exists(abs_path):
            test_syntax.set_target_file(abs_path)

    # Format and Viewing
    if args.update:
        for config, test in test_syntax.gather_test_params():
            test_syntax.compare_results(config, test, args.update)
    else:
        if not args.test_target or args.test_target[0] == 'syntax':
            test_syntax.run()
        if not args.test_target or args.test_target[0] == 'targeted':
            test_targeted.run()


if __name__ == '__main__':
    main()