Skip to content

Clean-up Tests #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
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.
  • Loading branch information
vmuriart committed Jan 31, 2017
commit 0e26b1a43dd81ef7ce6dfcf7d40fa96730855067
4 changes: 4 additions & 0 deletions src/tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
except ImportError:
print("Load clr import hook")
import clr
clr.AddReference("Python.Test")
clr.AddReference("System.Collections")
clr.AddReference("System.Data")
clr.AddReference("System.Management")

test_modules = (
# Passes on its own, but not here if
Expand Down
4 changes: 4 additions & 0 deletions src/tests/stresstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
except ImportError:
print("Load clr import hook")
import clr
clr.AddReference("Python.Test")
clr.AddReference("System.Collections")
clr.AddReference("System.Data")
clr.AddReference("System.Management")


def main():
Expand Down
8 changes: 0 additions & 8 deletions src/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,11 +1480,3 @@ def test():

def test_suite():
return unittest.makeSuite(ArrayTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
9 changes: 0 additions & 9 deletions src/tests/test_class.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

import clr
import types
import unittest

Expand Down Expand Up @@ -280,11 +279,3 @@ def kind(self):

def test_suite():
return unittest.makeSuite(ClassTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
17 changes: 0 additions & 17 deletions src/tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ def testDottedNameImportFromWithAlias(self):

def testFromModuleImportStar(self):
"""Test from module import * behavior."""
import clr
clr.AddReference("System.Management")

count = len(locals().keys())
m = __import__('CLR.System.Management', globals(), locals(), ['*'])
self.assertTrue(m.__name__ == 'System.Management')
Expand Down Expand Up @@ -262,17 +259,3 @@ def test000MultipleImports(self):

def test_suite():
return unittest.makeSuite(CompatibilityTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
try:
import System
except ImportError:
print("Load clr import hook")
import clr

main()
12 changes: 0 additions & 12 deletions src/tests/test_constructors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# -*- coding: utf-8 -*-

import unittest
import clr

clr.AddReference("Python.Test")
import Python.Test as Test
import System


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

def test_suite():
return unittest.makeSuite(ConstructorTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,3 @@ def testSByteArrayConversion(self):

def test_suite():
return unittest.makeSuite(ConversionTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
12 changes: 0 additions & 12 deletions src/tests/test_delegate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-

import clr

clr.AddReference('Python.Test')

from Python.Test import DelegateTest, PublicDelegate
from Python.Test import StringDelegate, ObjectDelegate
from Python.Test import BoolDelegate
Expand Down Expand Up @@ -319,11 +315,3 @@ def always_so_negative():

def test_suite():
return unittest.makeSuite(DelegateTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
11 changes: 0 additions & 11 deletions src/tests/test_docstring.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

import unittest
import clr

clr.AddReference('Python.Test')

from Python.Test import DocWithCtorTest, DocWithoutCtorTest, DocWithCtorNoDocTest

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

def test_suite():
return unittest.makeSuite(DocStringTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,3 @@ def testRunString(self):

def test_suite():
return unittest.makeSuite(EngineTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,3 @@ def test():

def test_suite():
return unittest.makeSuite(EnumTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
12 changes: 0 additions & 12 deletions src/tests/test_event.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-

import clr

clr.AddReference('Python.Test')

import unittest
from Python.Test import EventTest, TestEventHandler
from Python.Test import TestEventArgs
Expand Down Expand Up @@ -678,11 +674,3 @@ def handler(self, sender, args):

def test_suite():
return unittest.makeSuite(EventTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,3 @@ def testChainedExceptions(self):

def test_suite():
return unittest.makeSuite(ExceptionTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,3 @@ def test():

def test_suite():
return unittest.makeSuite(FieldTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
11 changes: 0 additions & 11 deletions src/tests/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

import clr

clr.AddReference('Python.Test')

from System.Collections.Generic import Dictionary, List
import unittest
import Python.Test as Test
Expand Down Expand Up @@ -795,11 +792,3 @@ def testNestedGenericClass(self):

def test_suite():
return unittest.makeSuite(GenericTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
10 changes: 0 additions & 10 deletions src/tests/test_indexer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-

import unittest
import clr

clr.AddReference("Python.Test")
import Python.Test as Test
import six

Expand Down Expand Up @@ -679,11 +677,3 @@ def test():

def test_suite():
return unittest.makeSuite(IndexerTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,3 @@ def testExplicitCastToInterface(self):

def test_suite():
return unittest.makeSuite(InterfaceTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
11 changes: 0 additions & 11 deletions src/tests/test_method.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

import unittest
import clr

clr.AddReference("Python.Test")

from Python.Test import MethodTest, MethodTestSub
import System
Expand Down Expand Up @@ -786,11 +783,3 @@ def testWeCanBindToEncodingGetString(self):

def test_suite():
return unittest.makeSuite(MethodTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
16 changes: 3 additions & 13 deletions src/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

import clr

clr.AddReference('Python.Test')
clr.AddReference('System.Data')

# testImplicitAssemblyLoad() passes on deprecation warning; perfect! #
##clr.AddReference('System.Windows.Forms')
import unittest
import types
import warnings
Expand All @@ -18,6 +13,9 @@
else:
ClassType = types.ClassType

# testImplicitAssemblyLoad() passes on deprecation warning; perfect! #
# clr.AddReference('System.Windows.Forms')


class ModuleTests(unittest.TestCase):
"""Test CLR modules and the CLR import hook."""
Expand Down Expand Up @@ -383,11 +381,3 @@ def test_AssemblyLoadThreadSafety(self):

def test_suite():
return unittest.makeSuite(ModuleTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
8 changes: 0 additions & 8 deletions src/tests/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,3 @@ def testInterfaceProperty(self):

def test_suite():
return unittest.makeSuite(PropertyTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
12 changes: 0 additions & 12 deletions src/tests/test_subclass.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# -*- coding: utf-8 -*-

import clr

clr.AddReference('Python.Test')
clr.AddReference('System')

import unittest
from Python.Test import TestFunctions, SubClassTest, IInterfaceTest, TestEventArgs
from System.Collections.Generic import List
Expand Down Expand Up @@ -167,11 +163,3 @@ def test_isinstance(self):

def test_suite():
return unittest.makeSuite(SubClassTests)


def main():
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()
9 changes: 0 additions & 9 deletions src/tests/test_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,3 @@ def start_threads(count):

def test_suite():
return unittest.makeSuite(ThreadTests)


def main():
for i in range(50):
unittest.TextTestRunner().run(test_suite())


if __name__ == '__main__':
main()