Skip to content
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

Get rid of DeprecationWarnings during unit tests #1093

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/OFS/tests/testChownRecursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ def testRecursiveChangeOwnership(self):


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestRecursiveChangeOwnership),
))
return unittest.defaultTestLoader.loadTestsFromTestCase(
TestRecursiveChangeOwnership)
9 changes: 5 additions & 4 deletions src/OFS/tests/testTraverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,9 @@ def test_view_doesnt_shadow_attribute():


def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestTraverse))
from Testing.ZopeTestCase import FunctionalDocTestSuite
suite.addTest(FunctionalDocTestSuite())
return suite

return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestTraverse),
FunctionalDocTestSuite(),
))
9 changes: 5 additions & 4 deletions src/OFS/tests/test_Uninstalled.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def test_Broken_instance___getstate___gives_access_to_its_state(self):


def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestsOfBroken))
suite.addTest(unittest.makeSuite(TestsIntegratedBroken))
return suite
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestsOfBroken),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestsIntegratedBroken),
))
4 changes: 2 additions & 2 deletions src/Products/Five/browser/tests/pages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ try to access some protected stuff. Let's not forgot to login again,
of course:

>>> from AccessControl import allow_module
>>> allow_module('smtpd')
>>> allow_module('pprint')
>>> self.logout()
>>> view = self.folder.unrestrictedTraverse('testoid/security.html')
>>> print(view())
<div>NoneType</div>
<div>smtpd</div>
<div>pprint</div>
>>> self.login('manager')

Test pages registered through the <five:pagesFromDirectory /> directive:
Expand Down
4 changes: 2 additions & 2 deletions src/Products/Five/browser/tests/security.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div tal:define="comment string:Testing unrestricted code"
tal:content="python:None.__class__.__name__" />
<div tal:define="comment string:Testing unrestricted modules access;
smtpd nocall:modules/smtpd"
tal:content="python:smtpd.__name__" />
pprint nocall:modules/pprint"
tal:content="python:pprint.__name__" />
3 changes: 2 additions & 1 deletion src/Products/Five/browser/tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ def test_suite():
from Testing.ZopeTestCase import FunctionalDocFileSuite
from Testing.ZopeTestCase import ZopeDocFileSuite
from Testing.ZopeTestCase import ZopeDocTestSuite

return unittest.TestSuite((
ZopeDocTestSuite(),
unittest.makeSuite(TestPublishTraverse),
unittest.defaultTestLoader.loadTestsFromTestCase(TestPublishTraverse),
ZopeDocFileSuite('pages.txt', package='Products.Five.browser.tests'),
FunctionalDocFileSuite('pages_ftest.txt',
package='Products.Five.browser.tests'),
Expand Down
19 changes: 11 additions & 8 deletions src/Products/PageTemplates/tests/testZopePageTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,15 @@ def read(self):

def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ZPTRegressions),
unittest.makeSuite(ZPTUtilsTests),
unittest.makeSuite(ZPTMacros),
unittest.makeSuite(ZopePageTemplateFileTests),
unittest.makeSuite(ZPTUnicodeEncodingConflictResolution),
unittest.makeSuite(ZPTBrowserTests),
unittest.makeSuite(PreferredCharsetUnicodeResolverTests),
unittest.makeSuite(SrcTests),
unittest.defaultTestLoader.loadTestsFromTestCase(ZPTRegressions),
unittest.defaultTestLoader.loadTestsFromTestCase(ZPTUtilsTests),
unittest.defaultTestLoader.loadTestsFromTestCase(ZPTMacros),
unittest.defaultTestLoader.loadTestsFromTestCase(
ZopePageTemplateFileTests),
unittest.defaultTestLoader.loadTestsFromTestCase(
ZPTUnicodeEncodingConflictResolution),
unittest.defaultTestLoader.loadTestsFromTestCase(ZPTBrowserTests),
unittest.defaultTestLoader.loadTestsFromTestCase(
PreferredCharsetUnicodeResolverTests),
unittest.defaultTestLoader.loadTestsFromTestCase(SrcTests),
))
4 changes: 1 addition & 3 deletions src/Products/PageTemplates/tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,4 @@ def test_macros_access(self):


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestPatches),
))
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPatches)
5 changes: 2 additions & 3 deletions src/Products/PageTemplates/tests/test_pagetemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,5 @@ def test_secure(self):


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestPageTemplateFile),
))
return unittest.defaultTestLoader.loadTestsFromTestCase(
TestPageTemplateFile)
4 changes: 1 addition & 3 deletions src/Products/PageTemplates/tests/test_persistenttemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,4 @@ def test_python_nbsp(self):


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestPersistent),
))
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPersistent)
5 changes: 2 additions & 3 deletions src/Products/PageTemplates/tests/test_viewpagetemplatefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,5 @@ def test_processing_instruction(self):


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestPageTemplateFile),
))
return unittest.defaultTestLoader.loadTestsFromTestCase(
TestPageTemplateFile)
29 changes: 15 additions & 14 deletions src/Testing/ZopeTestCase/testBaseTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
way of getting started.
"""
import gc
import unittest

import transaction
from AccessControl import getSecurityManager
Expand Down Expand Up @@ -451,17 +452,17 @@ def testClearClosesRequest(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestTestCase))
suite.addTest(makeSuite(TestSetUpRaises))
suite.addTest(makeSuite(TestTearDownRaises))
suite.addTest(makeSuite(TestConnectionRegistry))
suite.addTest(makeSuite(TestApplicationRegistry))
suite.addTest(makeSuite(TestListConverter))
suite.addTest(makeSuite(TestRequestVariables))
suite.addTest(makeSuite(TestRequestGarbage1))
suite.addTest(makeSuite(TestRequestGarbage2))
suite.addTest(makeSuite(TestRequestGarbage3))
return suite
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(TestSetUpRaises),
unittest.defaultTestLoader.loadTestsFromTestCase(TestTearDownRaises),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestConnectionRegistry),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestApplicationRegistry),
unittest.defaultTestLoader.loadTestsFromTestCase(TestListConverter),
unittest.defaultTestLoader.loadTestsFromTestCase(TestRequestVariables),
unittest.defaultTestLoader.loadTestsFromTestCase(TestRequestGarbage1),
unittest.defaultTestLoader.loadTestsFromTestCase(TestRequestGarbage2),
unittest.defaultTestLoader.loadTestsFromTestCase(TestRequestGarbage3),
))
8 changes: 3 additions & 5 deletions src/Testing/ZopeTestCase/testFunctional.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ def testSecurityContext(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestFunctional))
return suite
import unittest

return unittest.defaultTestLoader.loadTestsFromTestCase(TestFunctional)
19 changes: 10 additions & 9 deletions src/Testing/ZopeTestCase/testInterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"""Interface tests
"""

import unittest

from Testing.ZopeTestCase import Functional
from Testing.ZopeTestCase import FunctionalTestCase
from Testing.ZopeTestCase import PortalTestCase
Expand Down Expand Up @@ -91,12 +93,11 @@ def testIPortalSecurity(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestAbstractClasses))
suite.addTest(makeSuite(TestBaseTestCase))
suite.addTest(makeSuite(TestZopeTestCase))
suite.addTest(makeSuite(TestFunctionalTestCase))
suite.addTest(makeSuite(TestPortalTestCase))
return suite
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestAbstractClasses),
unittest.defaultTestLoader.loadTestsFromTestCase(TestBaseTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(TestZopeTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestFunctionalTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(TestPortalTestCase),
))
8 changes: 3 additions & 5 deletions src/Testing/ZopeTestCase/testPlaceless.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"""Placeless setup tests
"""

import unittest

from Testing import ZopeTestCase
from Testing.ZopeTestCase.placeless import setUp
from Testing.ZopeTestCase.placeless import tearDown
Expand Down Expand Up @@ -117,8 +119,4 @@ def testDecoratedFuncLoadsZCMLIterable(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestPlacelessSetUp))
return suite
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPlacelessSetUp)
17 changes: 9 additions & 8 deletions src/Testing/ZopeTestCase/testPortalTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
way of getting started.
"""

import unittest

import transaction
from AccessControl import getSecurityManager
from Acquisition import aq_base
Expand Down Expand Up @@ -518,11 +520,10 @@ def testTrigger(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestPortalTestCase))
suite.addTest(makeSuite(TestPlainUserFolder))
suite.addTest(makeSuite(TestWrappingUserFolder))
suite.addTest(makeSuite(TestSetUpRaises))
return suite
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestPortalTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(TestPlainUserFolder),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestWrappingUserFolder),
unittest.defaultTestLoader.loadTestsFromTestCase(TestSetUpRaises),
))
8 changes: 3 additions & 5 deletions src/Testing/ZopeTestCase/testSkeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def testSomething(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestSomeProduct))
return suite
import unittest

return unittest.defaultTestLoader.loadTestsFromTestCase(TestSomeProduct)
19 changes: 10 additions & 9 deletions src/Testing/ZopeTestCase/testZODBCompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import os
import tempfile
import unittest

from AccessControl.Permissions import add_documents_images_and_files
from AccessControl.Permissions import delete_objects
Expand Down Expand Up @@ -336,12 +337,12 @@ def testTransactionAbort(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestCopyPaste))
suite.addTest(makeSuite(TestImportExport))
suite.addTest(makeSuite(TestAttributesOfCleanObjects))
suite.addTest(makeSuite(TestAttributesOfDirtyObjects))
suite.addTest(makeSuite(TestTransactionAbort))
return suite
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestCopyPaste),
unittest.defaultTestLoader.loadTestsFromTestCase(TestImportExport),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestAttributesOfCleanObjects),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestAttributesOfDirtyObjects),
unittest.defaultTestLoader.loadTestsFromTestCase(TestTransactionAbort),
))
15 changes: 8 additions & 7 deletions src/Testing/ZopeTestCase/testZopeTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
way of getting started.
"""

import unittest

import transaction
from AccessControl import getSecurityManager
from Acquisition import aq_base
Expand Down Expand Up @@ -391,10 +393,9 @@ def testLoggedInUserIsWrapped(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestZopeTestCase))
suite.addTest(makeSuite(TestPlainUserFolder))
suite.addTest(makeSuite(TestWrappingUserFolder))
return suite
return unittest.TestSuite((
unittest.defaultTestLoader.loadTestsFromTestCase(TestZopeTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(TestPlainUserFolder),
unittest.defaultTestLoader.loadTestsFromTestCase(
TestWrappingUserFolder),
))
dataflake marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 2 additions & 5 deletions src/Testing/ZopeTestCase/zopedoctest/testAuthHeaderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"""Test for auth_header
"""

from unittest import TestSuite
from unittest import makeSuite
import unittest

from Testing.ZopeTestCase import TestCase
from Testing.ZopeTestCase import zopedoctest
Expand Down Expand Up @@ -49,6 +48,4 @@ def test_auth_non_encoded_colon(self):


def test_suite():
return TestSuite((
makeSuite(AuthHeaderTestCase),
))
return unittest.defaultTestLoader.loadTestsFromTestCase(AuthHeaderTestCase)
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def setUp(self):

def test_suite():
return unittest.TestSuite((
unittest.makeSuite(HTTPHeaderOutputTests),
unittest.defaultTestLoader.loadTestsFromTestCase(
HTTPHeaderOutputTests),
FunctionalDocTestSuite(setUp=setUp),
FunctionalDocFileSuite('FunctionalDocTest.txt', setUp=setUp),
))
7 changes: 2 additions & 5 deletions src/Testing/tests/test_testbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Tests for the testbrowser module.
"""

import unittest
from urllib.error import HTTPError

import transaction
Expand Down Expand Up @@ -192,8 +193,4 @@ def test_headers_camel_case(self):


def test_suite():
from unittest import TestSuite
from unittest import makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestTestbrowser))
return suite
return unittest.defaultTestLoader.loadTestsFromTestCase(TestTestbrowser)
4 changes: 1 addition & 3 deletions src/Zope2/App/tests/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,4 @@ def test_interface(self):


def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(StartupTests))
return suite
return unittest.defaultTestLoader.loadTestsFromTestCase(StartupTests)
dataflake marked this conversation as resolved.
Show resolved Hide resolved