X Tutup
Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit fb71914

Browse files
committed
Sanitize how to run tests
* Remove unsupported entry points * Adds reference to Python.Test by default for all tests * Remove redundant add_reference * Avoid some implicit AddReferences that were being done Not all tests added reference to Python.Test consistently. Solve this by making `run_test` the only supported method.
1 parent 402bfcf commit fb71914

22 files changed

+11
-203
lines changed

src/tests/runtests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
except ImportError:
1717
print("Load clr import hook")
1818
import clr
19+
clr.AddReference("Python.Test")
20+
clr.AddReference("System.Collections")
21+
clr.AddReference("System.Data")
22+
clr.AddReference("System.Management")
1923

2024
test_modules = (
2125
# Passes on its own, but not here if

src/tests/stresstest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
except ImportError:
1919
print("Load clr import hook")
2020
import clr
21+
clr.AddReference("Python.Test")
22+
clr.AddReference("System.Collections")
23+
clr.AddReference("System.Data")
24+
clr.AddReference("System.Management")
2125

2226

2327
def main():

src/tests/test_array.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,11 +1480,3 @@ def test():
14801480

14811481
def test_suite():
14821482
return unittest.makeSuite(ArrayTests)
1483-
1484-
1485-
def main():
1486-
unittest.TextTestRunner().run(test_suite())
1487-
1488-
1489-
if __name__ == '__main__':
1490-
main()

src/tests/test_class.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import clr
43
import types
54
import unittest
65

@@ -280,11 +279,3 @@ def kind(self):
280279

281280
def test_suite():
282281
return unittest.makeSuite(ClassTests)
283-
284-
285-
def main():
286-
unittest.TextTestRunner().run(test_suite())
287-
288-
289-
if __name__ == '__main__':
290-
main()

src/tests/test_compat.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ def testDottedNameImportFromWithAlias(self):
159159

160160
def testFromModuleImportStar(self):
161161
"""Test from module import * behavior."""
162-
import clr
163-
clr.AddReference("System.Management")
164-
165162
count = len(locals().keys())
166163
m = __import__('CLR.System.Management', globals(), locals(), ['*'])
167164
self.assertTrue(m.__name__ == 'System.Management')
@@ -262,17 +259,3 @@ def test000MultipleImports(self):
262259

263260
def test_suite():
264261
return unittest.makeSuite(CompatibilityTests)
265-
266-
267-
def main():
268-
unittest.TextTestRunner().run(test_suite())
269-
270-
271-
if __name__ == '__main__':
272-
try:
273-
import System
274-
except ImportError:
275-
print("Load clr import hook")
276-
import clr
277-
278-
main()

src/tests/test_constructors.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
import unittest
4-
import clr
5-
6-
clr.AddReference("Python.Test")
7-
import Python.Test as Test
84
import System
95

106

@@ -51,11 +47,3 @@ class sub(System.Exception):
5147

5248
def test_suite():
5349
return unittest.makeSuite(ConstructorTests)
54-
55-
56-
def main():
57-
unittest.TextTestRunner().run(test_suite())
58-
59-
60-
if __name__ == '__main__':
61-
main()

src/tests/test_conversion.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,3 @@ def testSByteArrayConversion(self):
836836

837837
def test_suite():
838838
return unittest.makeSuite(ConversionTests)
839-
840-
841-
def main():
842-
unittest.TextTestRunner().run(test_suite())
843-
844-
845-
if __name__ == '__main__':
846-
main()

src/tests/test_delegate.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import clr
4-
5-
clr.AddReference('Python.Test')
6-
73
from Python.Test import DelegateTest, PublicDelegate
84
from Python.Test import StringDelegate, ObjectDelegate
95
from Python.Test import BoolDelegate
@@ -319,11 +315,3 @@ def always_so_negative():
319315

320316
def test_suite():
321317
return unittest.makeSuite(DelegateTests)
322-
323-
324-
def main():
325-
unittest.TextTestRunner().run(test_suite())
326-
327-
328-
if __name__ == '__main__':
329-
main()

src/tests/test_docstring.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
import unittest
4-
import clr
5-
6-
clr.AddReference('Python.Test')
74

85
from Python.Test import DocWithCtorTest, DocWithoutCtorTest, DocWithCtorNoDocTest
96

@@ -29,11 +26,3 @@ def testDocWithoutCtor(self):
2926

3027
def test_suite():
3128
return unittest.makeSuite(DocStringTests)
32-
33-
34-
def main():
35-
unittest.TextTestRunner().run(test_suite())
36-
37-
38-
if __name__ == '__main__':
39-
main()

src/tests/test_engine.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,3 @@ def testRunString(self):
3939

4040
def test_suite():
4141
return unittest.makeSuite(EngineTests)
42-
43-
44-
def main():
45-
unittest.TextTestRunner().run(test_suite())
46-
47-
48-
if __name__ == '__main__':
49-
main()

0 commit comments

Comments
 (0)
X Tutup