Skip to content

JIT: test_unittest fails with -X lazy_imports=all: unittest.main is a module #158086

Description

@ashm-dev

Bug report

Bug description:

Six tests in test_unittest.test_program fail when the test suite is run with -X lazy_imports=all:

./python -X lazy_imports=all -m test test_unittest
ERROR: test_Exit (test.test_unittest.test_program.Test_TestProgram.test_Exit)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_unittest/test_program.py", line 150, in test_Exit
    unittest.main(
    ~~~~~~~~~~~~~^
        argv=["foobar"],
        ...
TypeError: 'module' object is not callable

The same error occurs in test_ExitAsDefault, test_ExitEmptySuite, test_ExitSetUpClassFailureSuite, test_ExitSkippedSuite and test_NonExit.

unittest.main resolves to the unittest.main submodule instead of the unittest.main.TestProgram class.

Without -X lazy_imports=all the tests pass.

Build configuration:

CC=clang-21 CXX=clang++-21 LDFLAGS='-fuse-ld=lld-21' ./configure --enable-experimental-jit=yes

CPython versions tested on:

CPython main branch, 3.16

Operating systems tested on:

Linux

Linked PRs

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions