4343.. moduleauthor:: Olaf Conradi <olaf@conradi.org>
4444"""
4545
46+ # TODO: The code below contains a small CLI test-runner (`TestRunner`), a
47+ # unittest-based `EarlTestResult`, and the `__main__` entrypoint. This file
48+ # is still kept to reuse `Manifest`, `Test` and `EarlReport` from the
49+ # original runner, but when running under `pytest` the separate
50+ # `tests/conftest.py` + `tests/test_manifests.py` integration is used to
51+ # drive tests. The `TestRunner` and `EarlTestResult` blocks can be removed
52+ # (or converted to a separate backward-compatibility script) once the
53+ # pytest migration is complete.
54+ # Also, the module docstring can be updated to reflect the pytest-based
55+ # testing approach once the legacy runner is removed.
56+
4657import datetime
4758import json
4859import os
4960import sys
5061import traceback
5162import unittest
5263import re
64+ # NOTE: ArgumentParser and TextTestResult were used by the original
65+ # TestRunner / EarlTestResult classes. They are obsolete because
66+ # pytest now provides the test harness; these imports can be removed
67+ # once the legacy CLI runner is deleted.
5368from argparse import ArgumentParser
5469from unittest import TextTestResult
5570
6378SKIP_TESTS = []
6479ONLY_IDENTIFIER = None
6580
81+ # `LOCAL_BASES` lists remote bases used by the official JSON-LD test
82+ # repositories. When a test refers to a URL starting with one of these
83+ # bases the runner attempts to map that URL to a local file in the
84+ # test-suite tree (when possible) so tests can be run offline.
85+
86+
6687LOCAL_BASES = [
6788 'https://w3c.github.io/json-ld-api/tests' ,
6889 'https://w3c.github.io/json-ld-framing/tests' ,
6990 'https://github.com/json-ld/normalization/tests'
7091]
7192
72- # `LOCAL_BASES` lists remote bases used by the official JSON-LD test
73- # repositories. When a test refers to a URL starting with one of these
74- # bases the runner attempts to map that URL to a local file in the
75- # test-suite tree (when possible) so tests can be run offline.
93+ # NOTE: The following TestRunner class can be removed because pytest now
94+ # provides the test harness; this class can be removed once the legacy
95+ # CLI runner is deleted.
7696
7797class TestRunner (unittest .TextTestRunner ):
7898 """
@@ -94,7 +114,7 @@ def _makeResult(self):
94114
95115 def main (self ):
96116 print ('PyLD Tests' )
97- print ('Use -h or --help to view options.\n ' )
117+ print ('Use -h or --help to view options.\\ n' )
98118
99119 # add program options
100120 self .parser .add_argument ('tests' , metavar = 'TEST' , nargs = '*' ,
@@ -715,7 +735,9 @@ def local_loader(url, headers):
715735
716736 return local_loader
717737
718-
738+ # NOTE: The EarlTestResult class can be removed because pytest now
739+ # provides the test harness; this class can be removed once the legacy
740+ # CLI runner is deleted.
719741class EarlTestResult (TextTestResult ):
720742 """
721743 A `TextTestResult` subclass that records EARL assertions as tests run.
@@ -1054,5 +1076,8 @@ def write(self, filename):
10541076}
10551077
10561078
1079+ # NOTE: The legacy command-line entrypoint can be removed because pytest is used to
1080+ # run the test-suite. Keep this here for reference; it can be removed once
1081+ # the pytest migration is finalized.
10571082if __name__ == '__main__' :
10581083 TestRunner (verbosity = 2 ).main ()
0 commit comments