annotate tests/_tsetup.py @ 20:3db60b64abf6

Allow also "!=" as inequality operator (in addition to "<>")
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 20 Apr 2026 15:28:19 +0200
parents 859ab8abce0a
children de1f67eff9d5
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
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 import logging
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 import os
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13 import sys
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15
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
16 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
17 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
18 sys.path.insert(0, PROJECTDIR)
859ab8abce0a The first real tests about lexing with the Pygments API for the tests.
Franz Glasner <fzglas.hg@dom66.de>
parents: 17
diff changeset
19 LEXERFILENAME = os.path.join(PROJECTDIR,
859ab8abce0a The first real tests about lexing with the Pygments API for the tests.
Franz Glasner <fzglas.hg@dom66.de>
parents: 17
diff changeset
20 "pygments_lexer_pseudocode2/__init__.py")
859ab8abce0a The first real tests about lexing with the Pygments API for the tests.
Franz Glasner <fzglas.hg@dom66.de>
parents: 17
diff changeset
21 LEXERCLASS = "PseudocodeLexer2"
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
22 TESTSNIPPETSDIR = os.path.join(
16
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 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
24 "snippets")
16
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27 # 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
28 logging.captureWarnings(True)
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29 logging.basicConfig(
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30 level=logging.DEBUG,
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31 style='%',
b92f660f2461 Begin a test infrastructure: using unittest and flake8.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32 format="[%(name)s][%(filename)s:%(lineno)d:%(funcName)s][%(levelname)s] %(message)s") # noqa: E501 (line too long)