Skip to content

Commit bd1ce40

Browse files
committed
Add notes about what can possibly be deleted after pytest migration
1 parent 9e8b5bc commit bd1ce40

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

tests/runtests.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,28 @@
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+
4657
import datetime
4758
import json
4859
import os
4960
import sys
5061
import traceback
5162
import unittest
5263
import 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.
5368
from argparse import ArgumentParser
5469
from unittest import TextTestResult
5570

@@ -63,16 +78,21 @@
6378
SKIP_TESTS = []
6479
ONLY_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+
6687
LOCAL_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

7797
class 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.
719741
class 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.
10571082
if __name__ == '__main__':
10581083
TestRunner(verbosity=2).main()

0 commit comments

Comments
 (0)