summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3-jsonpointer/0001-Clean-up-test-runner.patch
blob: 4121834dbfbf74abab457fd180f36cd649d7f7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 04a864f33848da6af1dea906ba4922770022ef66 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Thu, 16 Mar 2023 14:21:32 +0000
Subject: [PATCH] Clean up test runner

Test code doesn't need to manually construct a TestSuite and a
TextTestRunner, the unittest module has a discovery function that does
all this for you.

Delete all of the manual logic from tests.py, replace it with the two
lines to bring in the doctest unit tests, and update the makefile to
run the unittest discovery.

Upstream-Status: Submitted [https://github.com/stefankoegl/python-json-pointer/pull/54]
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 makefile |  2 +-
 tests.py | 24 ++++--------------------
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/tests.py b/tests.py
index 9252369..6b4b8cc 100755
--- a/tests.py
+++ b/tests.py
@@ -7,6 +7,7 @@ import doctest
 import unittest
 import sys
 import copy
+import jsonpointer
 from jsonpointer import resolve_pointer, EndOfList, JsonPointerException, \
          JsonPointer, set_pointer
 
@@ -410,23 +411,6 @@ class AltTypesTests(unittest.TestCase):
         self.assertRaises(JsonPointerException, resolve_pointer, doc, '/root/1/2/3/4')
 
 
-
-suite = unittest.TestSuite()
-suite.addTest(unittest.makeSuite(SpecificationTests))
-suite.addTest(unittest.makeSuite(ComparisonTests))
-suite.addTest(unittest.makeSuite(WrongInputTests))
-suite.addTest(unittest.makeSuite(ToLastTests))
-suite.addTest(unittest.makeSuite(SetTests))
-suite.addTest(unittest.makeSuite(AltTypesTests))
-
-modules = ['jsonpointer']
-
-for module in modules:
-    m = __import__(module, fromlist=[module])
-    suite.addTest(doctest.DocTestSuite(m))
-
-runner = unittest.TextTestRunner(verbosity=1)
-result = runner.run(suite)
-
-if not result.wasSuccessful():
-    sys.exit(1)
+def load_tests(loader, tests, ignore):
+    tests.addTests(doctest.DocTestSuite(jsonpointer))
+    return tests
-- 
2.34.1