GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Move all stdlib tests in the test package · Issue #93839 · python/cpython

Move all stdlib tests in the test package #93839

New issue
Copy link
New issue
Copy link
Closed
Closed
Move all stdlib tests in the test package#93839
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@vstinner
vstinner
opened on Jun 15, 2022
Issue body actions

Currently, Python tests are scattered in multiple directories:

  • Lib/test/ (main one)
  • Lib/ctypes/test/
  • Lib/distutils/tests/
  • Lib/idlelib/idle_test/
  • Lib/lib2to3/tests/
  • Lib/tkinter/test/
  • Lib/unittest/test/

idlelib, ctypes, lib2to3, tkinter, unittest and distutils have their tests under their own packages. It causes multiple issues:

  • As a maintainer of Python, I have to look into these directories manually when refactoring "Python tests" (I cannot just look into Lib/test/).
  • Linux distributions have to manually put these directories into a separated packages if they want to make the main "python" package smaller, to put python tests into a separated package.
  • Makefile is more complicated since tests are installed separately, and so these directories should be listed explicitly in the TESTSUBDIRS variable.
  • Tools/scripts/generate_stdlib_module_names.py excludes manually these modules, since sys.stdlib_module_names excludes test modules.

I propose to move ctypes, idlelib, tkinter and unittest tests under Lib/test/.

For distutils and lib2to3, maybe we can just leave them where they are, since both modules are deprecated. distutils should be removed in Python 3.12. lib2to3 is scheduled for removal in Python 3.13.

Do you think that it's worth it to move these directories?

Reacted by Erlend E. Aasland
Reacted by Oleg Iarygin and Erlend E. Aasland

Activity

  1. vstinner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jun 15, 2022
  2. vstinner commented on Jun 15, 2022

    @vstinner
    vstinner
    on Jun 15, 2022
    MemberAuthor
    More actions

    It seems like the Windows installer only treat Lib/test/ separately: see Tools/msi/test/test.wixproj. I would be nice to also exclude the other test directories to make Python installation smaller on Windows.

    $ du -sh ctypes/test/ distutils/tests/ idlelib/idle_test/ lib2to3/tests/ tkinter/test/ unittest/test/
    348K	ctypes/test/
    336K	distutils/tests/
    624K	idlelib/idle_test/
    440K	lib2to3/tests/
    284K	tkinter/test/
    700K	unittest/test/
    

    The total is about 2 732 KB.

    On Fedora 36, the Python 3.10 tests (python3-test package) take around 54 MB in total (it includes idle_test, ctypes tests, etc.).

    $ sudo dnf install python3-test
    (...)
    Total download size: 9.7 M
    Installed size: 54 M
    
  3. rhettinger commented on Jun 15, 2022

    @rhettinger
    rhettinger
    on Jun 15, 2022
    Contributor
    More actions

    Do you think that it's worth it to move these directories?

    Yes, yes, yes!

  4. zware commented on Jun 15, 2022

    @zware
    zware
    on Jun 15, 2022
    Member
    More actions

    This appears to duplicate #54781.

    I'm still in favor :)

    Reacted by Ezio Melotti
  5. vstinner commented on Jun 20, 2022

    @vstinner
    vstinner
    on Jun 20, 2022
    MemberAuthor
    More actions

    I started with:

    • ctypes: PR gh-93839: Move Lib/ctypes/test/ to Lib/test/test_ctypes/ #94041
    • unittest: PR gh-93839: Move Lib/unttest/test/ to Lib/test/test_unittest/ #94043
  6. terryjreedy commented on Jun 21, 2022

    @terryjreedy
    terryjreedy
    on Jun 21, 2022
    Member
    More actions

    Please leave idlelib/idle_test alone. Following gives some of reasons:
    #54781 (comment)
    There are also several references to files in this directory in idlelib and idlelib.test_idle files.

  7. merwok commented on Jun 21, 2022

    @merwok
    merwok
    on Jun 21, 2022
    Member
    More actions

    Could you exclude idle and distutils from your list, and attach the new PRs to the other ticket?

  8. vstinner
    added 2 commits that reference this issue on Jun 21, 2022

    gh-93839: Move Lib/ctypes/test/ to Lib/test/test_ctypes/ (#94041)

    d82e0bf

    gh-93839: Move Lib/unttest/test/ to Lib/test/test_unittest/ (#94043)

    c735d54
  9. vstinner commented on Jun 21, 2022

    @vstinner
    vstinner
    on Jun 21, 2022
    MemberAuthor
    More actions

    I merged my ctypes and unittest PRs. Ok, let's continue in issue #54781.

  10. vstinner
    closed this as completedon Jun 21, 2022
  11. tiran commented on Jun 21, 2022

    @tiran
    tiran
    on Jun 21, 2022
    Member
    More actions

    PR #94043 broke testing on all WebAssembly platforms.

  12. tiran
    reopened this on Jun 21, 2022
  13. vstinner commented on Jun 21, 2022

    @vstinner
    vstinner
    on Jun 21, 2022
    MemberAuthor
    More actions

    PR #94043 broke testing on all WebAssembly platforms.

    Please comment #54781. This issue is a duplicate.

  14. tiran commented on Jun 21, 2022

    @tiran
    tiran
    on Jun 21, 2022
    Member
    More actions

    Commit #94043 used this ticket as reference.

  15. tiran commented on Jun 21, 2022

    @tiran
    tiran
    on Jun 21, 2022
    Member
    More actions

    There are actually two problems:

    • Lib/test/test_unittest/init.py fails when a submodule raises SkipTest. This was supported before.
    • Re-running uses wrong interpreter to re-run the test, reported as "Re-running failed tests in verbose mode" does not use host runner #94052
    # wasmtime run --mapdir .::../../ -- python.wasm -m test -v test_unittest
    == CPython 3.12.0a0 (heads/main-dirty:c735d545343, Jun 21 2022, 09:30:50) [Clang 14.0.4 (https://github.com/llvm/llvm-project 29f1039a7285a5c3a9c353d05414
    == wasi-0.0.0-wasm32-32bit little-endian
    == cwd: /python-wasm/cpython/builddir/wasi/build/test_python_859108æ
    == CPU count: 1
    == encodings: locale=UTF-8, FS=utf-8
    0:00:00 Run tests sequentially
    0:00:00 [1/1] test_unittest
    Failed to call load_tests:
    Traceback (most recent call last):
      File "/Lib/unittest/loader.py", line 130, in loadTestsFromModule
        return load_tests(self, tests, pattern)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Lib/test/test_unittest/testmock/__init__.py", line 14, in load_tests
        __import__(modname)
        ^^^^^^^^^^^^^^^^^^^
      File "/Lib/test/test_unittest/testmock/testasync.py", line 9, in <module>
        support.requires_working_socket(module=True)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Lib/test/support/__init__.py", line 543, in requires_working_socket
        raise unittest.SkipTest(msg)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    unittest.case.SkipTest: requires socket support
    
    test test_unittest crashed -- Traceback (most recent call last):
      File "/Lib/test/libregrtest/runtest.py", line 360, in _runtest_inner
        refleak = _runtest_inner2(ns, test_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Lib/test/libregrtest/runtest.py", line 317, in _runtest_inner2
        test_runner()
        ^^^^^^^^^^^^^
      File "/Lib/test/libregrtest/runtest.py", line 280, in _test_module
        raise Exception("errors while loading tests")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Exception: errors while loading tests
    
    test_unittest failed (uncaught exception)
    
    == Tests result: FAILURE ==
    
    1 test failed:
        test_unittest
    
    Total duration: 132 ms
    Tests result: FAILURE
    
  16. tiran
    added a commit that references this issue on Jun 21, 2022

    pythongh-93839: Use load_package_tests() for testmock

    4b3670c
  17. miss-islington
    added a commit that references this issue on Jun 21, 2022

    gh-93839: Use load_package_tests() for testmock (GH-94055)

    50ebd72
  18. serhiy-storchaka
    added a commit that references this issue on Jun 26, 2022

    Revert 30935 defer bpo45162 to 312 (#94285)

    1ffde3e
  19. arhadthedev commented on Jun 29, 2022

    @arhadthedev
    arhadthedev
    on Jun 29, 2022
    Member
    More actions

    What's about Modules/_decimal/tests? Is it eligible for moving?

    • bench.py - move to pyperformance
    • formathelper.py, randdec.py, randfloat.py - convert these generators to unittest subtests
    • README.txt, runall-memorydebugger.sh, runall.bat - port to unittest and merge there
    • bignum.py, deccheck.py, formathelper.py, randdec.py, randfloat.py
  20. vstinner commented on Jun 29, 2022

    @vstinner
    vstinner
    on Jun 29, 2022
    MemberAuthor
    More actions

    What's about Modules/_decimal/tests? Is it eligible for moving?

    It's not installed by make install, so I care less about this one :-)

  21. erlend-aasland commented on Jul 20, 2022

    @erlend-aasland
    erlend-aasland
    on Jul 20, 2022
    Contributor
    More actions

    Are the issues mentioned by Christian resolved? Can we close this?

  22. tiran commented on Jul 20, 2022

    @tiran
    tiran
    on Jul 20, 2022
    Member
    More actions

    Yes, they are.

    Reacted by Erlend E. Aasland
  23. tiran
    closed this as completedon Jul 20, 2022
  24. eli-schwartz
    added a commit that references this issue on Dec 22, 2022

    pythongh-25177: fix bad rebase of moved test file

    1ff6ee3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.