Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame^] | 1 | From 04a864f33848da6af1dea906ba4922770022ef66 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ross Burton <ross.burton@arm.com> |
| 3 | Date: Thu, 16 Mar 2023 14:21:32 +0000 |
| 4 | Subject: [PATCH] Clean up test runner |
| 5 | |
| 6 | Test code doesn't need to manually construct a TestSuite and a |
| 7 | TextTestRunner, the unittest module has a discovery function that does |
| 8 | all this for you. |
| 9 | |
| 10 | Delete all of the manual logic from tests.py, replace it with the two |
| 11 | lines to bring in the doctest unit tests, and update the makefile to |
| 12 | run the unittest discovery. |
| 13 | |
| 14 | Upstream-Status: Submitted [https://github.com/stefankoegl/python-json-pointer/pull/54] |
| 15 | Signed-off-by: Ross Burton <ross.burton@arm.com> |
| 16 | --- |
| 17 | makefile | 2 +- |
| 18 | tests.py | 24 ++++-------------------- |
| 19 | 2 files changed, 5 insertions(+), 21 deletions(-) |
| 20 | |
| 21 | diff --git a/tests.py b/tests.py |
| 22 | index 9252369..6b4b8cc 100755 |
| 23 | --- a/tests.py |
| 24 | +++ b/tests.py |
| 25 | @@ -7,6 +7,7 @@ import doctest |
| 26 | import unittest |
| 27 | import sys |
| 28 | import copy |
| 29 | +import jsonpointer |
| 30 | from jsonpointer import resolve_pointer, EndOfList, JsonPointerException, \ |
| 31 | JsonPointer, set_pointer |
| 32 | |
| 33 | @@ -410,23 +411,6 @@ class AltTypesTests(unittest.TestCase): |
| 34 | self.assertRaises(JsonPointerException, resolve_pointer, doc, '/root/1/2/3/4') |
| 35 | |
| 36 | |
| 37 | - |
| 38 | -suite = unittest.TestSuite() |
| 39 | -suite.addTest(unittest.makeSuite(SpecificationTests)) |
| 40 | -suite.addTest(unittest.makeSuite(ComparisonTests)) |
| 41 | -suite.addTest(unittest.makeSuite(WrongInputTests)) |
| 42 | -suite.addTest(unittest.makeSuite(ToLastTests)) |
| 43 | -suite.addTest(unittest.makeSuite(SetTests)) |
| 44 | -suite.addTest(unittest.makeSuite(AltTypesTests)) |
| 45 | - |
| 46 | -modules = ['jsonpointer'] |
| 47 | - |
| 48 | -for module in modules: |
| 49 | - m = __import__(module, fromlist=[module]) |
| 50 | - suite.addTest(doctest.DocTestSuite(m)) |
| 51 | - |
| 52 | -runner = unittest.TextTestRunner(verbosity=1) |
| 53 | -result = runner.run(suite) |
| 54 | - |
| 55 | -if not result.wasSuccessful(): |
| 56 | - sys.exit(1) |
| 57 | +def load_tests(loader, tests, ignore): |
| 58 | + tests.addTests(doctest.DocTestSuite(jsonpointer)) |
| 59 | + return tests |
| 60 | -- |
| 61 | 2.34.1 |
| 62 | |