annotate tests/_tsetup.py @ 283:5eba722df93e

FIX: Some missing context position updates if a context is given
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 20 May 2026 17:31:20 +0200
parents a4317957148b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2 # :-
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 # SPDX-FileCopyrightText: © 2026 Franz Glasner
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4 # SPDX-License-Identifier: MIT
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 r"""Automatic unittest context configuration.
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 Side-effects of import configure the test environment!
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 """
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
11 __all__ = [
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
12 "PROJECTDIR",
53
39151225fb84 Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
13 "ALGLEXERCLASS",
39151225fb84 Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
14 "ALGLEXERFILENAME",
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
15 "FRLEXERCLASS",
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
16 "FRLEXERFILENAME",
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
17 "TESTSNIPPETSDIR",
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
18 ]
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
19
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
20
16
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 import logging
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 import os
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 import sys
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25
18
859ab8abce0a The first real tests about lexing with the Pygments API for the tests.
Franz Glasner <fzglas.hg@dom66.de>
parents: 17
diff changeset
26 PROJECTDIR = os.path.abspath(
859ab8abce0a The first real tests about lexing with the Pygments API for the tests.
Franz Glasner <fzglas.hg@dom66.de>
parents: 17
diff changeset
27 os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))
859ab8abce0a The first real tests about lexing with the Pygments API for the tests.
Franz Glasner <fzglas.hg@dom66.de>
parents: 17
diff changeset
28 sys.path.insert(0, PROJECTDIR)
28
de1f67eff9d5 Move the original French pseudocode lexter into a sub-module.
Franz Glasner <fzglas.hg@dom66.de>
parents: 18
diff changeset
29 FRLEXERFILENAME = os.path.join(PROJECTDIR,
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
30 "pygments_lexer_pseudocode2",
164
a4317957148b Move all lexers into a subpackage pygments_lexer_pseudocode2.lexers.
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
31 "lexers",
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents: 28
diff changeset
32 "fr_pseudocode.py")
28
de1f67eff9d5 Move the original French pseudocode lexter into a sub-module.
Franz Glasner <fzglas.hg@dom66.de>
parents: 18
diff changeset
33 FRLEXERCLASS = "FrPseudocodeLexer"
53
39151225fb84 Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
34 ALGLEXERFILENAME = os.path.join(PROJECTDIR,
39151225fb84 Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
35 "pygments_lexer_pseudocode2",
164
a4317957148b Move all lexers into a subpackage pygments_lexer_pseudocode2.lexers.
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
36 "lexers",
53
39151225fb84 Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
37 "algpseudocode.py")
39151225fb84 Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
38 ALGLEXERCLASS = "AlgPseudocodeLexer"
17
251898f2f0c7 The test data should live in "tests/snippets" for Pygments; rename "data" to "snippets"
Franz Glasner <fzglas.hg@dom66.de>
parents: 16
diff changeset
39 TESTSNIPPETSDIR = os.path.join(
16
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 os.path.abspath(os.path.dirname(__file__)),
17
251898f2f0c7 The test data should live in "tests/snippets" for Pygments; rename "data" to "snippets"
Franz Glasner <fzglas.hg@dom66.de>
parents: 16
diff changeset
41 "snippets")
16
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
43
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 # Setup logging for the unittests: use a known fixed format w/o time
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
45 logging.captureWarnings(True)
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46 logging.basicConfig(
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
47 level=logging.DEBUG,
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 style='%',
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 format="[%(name)s][%(filename)s:%(lineno)d:%(funcName)s][%(levelname)s] %(message)s") # noqa: E501 (line too long)