Skip to content

Conversation

@tiran
Copy link
Member

@tiran tiran commented Jun 21, 2022

Fixes failing tests on WebAssembly platforms.

Automerge-Triggered-By: GH:tiran

Fixes failing tests on WebAssembly platforms.
Copy link
Contributor

@cjw296 cjw296 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less code is always better!

@miss-islington
Copy link
Contributor

Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 50ebd72 into python:main Jun 21, 2022
@vstinner
Copy link
Member

I don't get why the old code only failed on WebAssembly, but I'm happy that the new more regular code just works :-)

@tiran
Copy link
Member Author

tiran commented Jun 21, 2022

The old code did __import__ without capturing and handling SkipTest exception from the import.

@vstinner
Copy link
Member

Example of error before the fix: https://buildbot.python.org/all/#/builders/1044/builds/35

FAIL: testSelectedTestNamesFunctionalTest (test.test_unittest.test_program.TestCommandLineArgs.testSelectedTestNamesFunctionalTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/test_program.py", line 468, in testSelectedTestNamesFunctionalTest
    self.assertIn('Ran 7 tests', run_unittest(['discover', '-p', '*_test*', '-k', 'TestWarnings']))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Ran 7 tests' not found in '/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:24: DeprecationWarning: Please use assertEqual instead.\n  self.assertEquals(2+2, 4)\n./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:38: DeprecationWarning: dw\n  warnings.warn(\'dw\', DeprecationWarning)\n/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:39: DeprecationWarning: dw\n  warnings.warn(\'dw\', DeprecationWarning)\n/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:40: DeprecationWarning: dw\n  warnings.warn(\'dw\', DeprecationWarning)\n./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:29: DeprecationWarning: Please use assertTrue instead.\n  self.failUnless(1)\n./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:18: RuntimeWarning: rw\n  warnings.warn(\'rw\', RuntimeWarning)\n./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:43: ImportWarning: iw\n  warnings.warn(\'iw\', ImportWarning)\n/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:44: ImportWarning: iw\n  warnings.warn(\'iw\', ImportWarning)\n/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:45: ImportWarning: iw\n  warnings.warn(\'iw\', ImportWarning)\n../opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:49: UserWarning: uw\n  warnings.warn(\'uw\')\n/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:50: UserWarning: uw\n  warnings.warn(\'uw\')\n/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:51: UserWarning: uw\n  warnings.warn(\'uw\')\n.E\n======================================================================\nERROR: testmock (unittest.loader._FailedTest.testmock)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/testmock/__init__.py", line 14, in load_tests\n    __import__(modname)\n    ^^^^^^^^^^^^^^^^^^^\n  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/__init__.py", line 2, in <module>\n    from test.support import load_package_tests\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/support/__init__.py", line 1229, in <module>\n    not sysconfig.get_config_var(\'WITH_DOC_STRINGS\'))\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/sysconfig.py", line 714, in get_config_var\n    return get_config_vars().get(name)\n           ^^^^^^^^^^^^^^^^^\n  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/sysconfig.py", line 669, in get_config_vars\n    _init_posix(_CONFIG_VARS)\n    ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/sysconfig.py", line 530, in _init_posix\n    _temp = __import__(name, globals(), locals(), [\'build_time_vars\'], 0)\n            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nModuleNotFoundError: No module named \'_sysconfigdata__emscripten_wasm32-emscripten\'\n\n----------------------------------------------------------------------\nRan 8 tests in 0.001s\n\nFAILED (errors=1)\n'

Reformatted output:

/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:24: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(2+2, 4)
./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:38: DeprecationWarning: dw
  warnings.warn(\'dw\', DeprecationWarning)
/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:39: DeprecationWarning: dw
  warnings.warn(\'dw\', DeprecationWarning)
/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:40: DeprecationWarning: dw
  warnings.warn(\'dw\', DeprecationWarning)
./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:29: DeprecationWarning: Please use assertTrue instead.
  self.failUnless(1)
./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:18: RuntimeWarning: rw
  warnings.warn(\'rw\', RuntimeWarning)
./opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:43: ImportWarning: iw
  warnings.warn(\'iw\', ImportWarning)
/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:44: ImportWarning: iw
  warnings.warn(\'iw\', ImportWarning)
/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:45: ImportWarning: iw
  warnings.warn(\'iw\', ImportWarning)
../opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:49: UserWarning: uw
  warnings.warn(\'uw\')
/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:50: UserWarning: uw
  warnings.warn(\'uw\')
/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/_test_warnings.py:51: UserWarning: uw
  warnings.warn(\'uw\')
.E
======================================================================
ERROR: testmock (unittest.loader._FailedTest.testmock)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/testmock/__init__.py", line 14, in load_tests
    __import__(modname)
    ^^^^^^^^^^^^^^^^^^^
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/test_unittest/__init__.py", line 2, in <module>
    from test.support import load_package_tests
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/test/support/__init__.py", line 1229, in <module>
    not sysconfig.get_config_var(\'WITH_DOC_STRINGS\'))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/sysconfig.py", line 714, in get_config_var
    return get_config_vars().get(name)
           ^^^^^^^^^^^^^^^^^
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/sysconfig.py", line 669, in get_config_vars
    _init_posix(_CONFIG_VARS)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/buildbot/bcannon-wasm/3.x.bcannon-wasm.emscripten-node/build/Lib/sysconfig.py", line 530, in _init_posix
    _temp = __import__(name, globals(), locals(), [\'build_time_vars\'], 0)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named \'_sysconfigdata__emscripten_wasm32-emscripten\'

----------------------------------------------------------------------
Ran 8 tests in 0.001s

FAILED (errors=1)

@vstinner
Copy link
Member

Oh, more context about this change:

On WebAssemble, Lib/test/test_unittest/testmock/testasync.py raises unittest.case.SkipTest: requires socket support.

@tiran
Copy link
Member Author

tiran commented Jun 21, 2022

Yeah, ModuleNotFoundError: No module named \'_sysconfigdata__emscripten_wasm32-emscripten\' is red herring. It took me a while to realize that it was a side-effect of bug gh-94052.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants