This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Modify test_socket.py to use unittest test discovery
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Support ./python -m unittest in test_socket
View: 14408
Assigned To: Nosy List: serhiy.storchaka, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2019-09-09 10:26 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15751 closed vstinner, 2019-09-09 10:27
Messages (6)
msg351409 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2019-09-09 10:31
See also #14408.
msg351418 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-09 10:44
Right now, test_main() is awful: 75 lines of code which is a very long list of class names! There are just 2 lines to check if tests don't leak a running thread.


def test_main():
    tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
             TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest,
             UDPTimeoutTest, CreateServerTest, CreateServerFunctionalTest]

    tests.extend([
        NonBlockingTCPTests,
        FileObjectClassTestCase,
        UnbufferedFileObjectClassTestCase,
        LineBufferedFileObjectClassTestCase,
        SmallBufferedFileObjectClassTestCase,
        UnicodeReadFileObjectClassTestCase,
        UnicodeWriteFileObjectClassTestCase,
        UnicodeReadWriteFileObjectClassTestCase,
        NetworkConnectionNoServer,
        NetworkConnectionAttributesTest,
        NetworkConnectionBehaviourTest,
        ContextManagersTest,
        InheritanceTest,
        NonblockConstantTest
    ])
    tests.append(BasicSocketPairTest)
    tests.append(TestUnixDomain)
    tests.append(TestLinuxAbstractNamespace)
    tests.extend([TIPCTest, TIPCThreadableTest])
    tests.extend([BasicCANTest, CANTest])
    tests.extend([BasicRDSTest, RDSTest])
    tests.append(LinuxKernelCryptoAPI)
    tests.append(BasicQIPCRTRTest)
    tests.extend([
        BasicVSOCKTest,
        ThreadedVSOCKSocketStreamTest,
    ])
    tests.append(BasicBluetoothTest)
    tests.extend([
        CmsgMacroTests,
        SendmsgUDPTest,
        RecvmsgUDPTest,
        RecvmsgIntoUDPTest,
        SendmsgUDP6Test,
        RecvmsgUDP6Test,
        RecvmsgRFC3542AncillaryUDP6Test,
        RecvmsgIntoRFC3542AncillaryUDP6Test,
        RecvmsgIntoUDP6Test,
        SendmsgUDPLITETest,
        RecvmsgUDPLITETest,
        RecvmsgIntoUDPLITETest,
        SendmsgUDPLITE6Test,
        RecvmsgUDPLITE6Test,
        RecvmsgRFC3542AncillaryUDPLITE6Test,
        RecvmsgIntoRFC3542AncillaryUDPLITE6Test,
        RecvmsgIntoUDPLITE6Test,
        SendmsgTCPTest,
        RecvmsgTCPTest,
        RecvmsgIntoTCPTest,
        SendmsgSCTPStreamTest,
        RecvmsgSCTPStreamTest,
        RecvmsgIntoSCTPStreamTest,
        SendmsgUnixStreamTest,
        RecvmsgUnixStreamTest,
        RecvmsgIntoUnixStreamTest,
        RecvmsgSCMRightsStreamTest,
        RecvmsgIntoSCMRightsStreamTest,
        # These are slow when setitimer() is not available
        InterruptedRecvTimeoutTest,
        InterruptedSendTimeoutTest,
        TestSocketSharing,
        SendfileUsingSendTest,
        SendfileUsingSendfileTest,
    ])
    tests.append(TestMSWindowsTCPFlags)

    thread_info = support.threading_setup()
    support.run_unittest(*tests)
    support.threading_cleanup(*thread_info)
msg351422 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-09 10:47
> See also #14408

In 2012, test_main() was used to skip a few test cases.

But since that time, the availability tests were moved from test_main() to the test case classes directly using unittest.skipIf or unittest.skipUnless decorators.

So now using unittest.main() became trivial.
msg361053 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-30 12:18
My PR 15751 didn't work. If someone else wants to give a try to fix this issue, please go ahead!
msg361764 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-11 00:04
I mark this issue as a duplicate of bpo-14408.
msg402079 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-17 19:24
I has merged similar PR in issue45187. Although it required to fix some existing bugs first.
History
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82244
2021-09-17 19:24:58serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg402079
2020-02-11 00:04:06vstinnersetstatus: open -> closed
superseder: Support ./python -m unittest in test_socket
messages: + msg361764

resolution: duplicate
stage: patch review -> resolved
2020-01-30 12:18:13vstinnersetmessages: + msg361053
2019-09-09 10:47:18vstinnersetmessages: + msg351422
2019-09-09 10:44:27vstinnersetmessages: + msg351418
2019-09-09 10:31:32zach.waresetnosy: + zach.ware
messages: + msg351409
2019-09-09 10:30:06vstinnersetversions: + Python 3.8
2019-09-09 10:27:19vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request15405
2019-09-09 10:26:30vstinnercreate