Skip to content

Conversation

@junkmd
Copy link
Collaborator

@junkmd junkmd commented Oct 29, 2025

A test for GetModuleFileName with a null handler was failing in virtual environments (like with uvx).

PS C:\path\to\prj\comtypes> uvx python -m unittest comtypes.test.test_typeinfo.Test_GetModuleFileName                  
test_invalid_handle (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_invalid_handle) ... ok                              
test_invalid_nsize (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_invalid_nsize) ... ok
test_loaded_module_handle (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_loaded_module_handle) ... ok
test_null_handler (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_null_handler) ... FAIL

======================================================================
FAIL: test_null_handler (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_null_handler)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\path\to\prj\comtypes\comtypes\test\test_typeinfo.py", line 100, in test_null_handler
    self.assertEqual(GetModuleFileName(None, MAX_PATH), sys.executable)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'C:\\[18 chars]ata\\Roaming\\uv\\python\\cpython-3.13.9-windo[22 chars].exe' != 'C:\\[18 chars]ata\\Local\\uv\\cache\\archive-v0\\fYwvsebcHXF[27 chars].exe'
- C:\path\to\prj\AppData\Roaming\uv\python\cpython-3.13.9-windows-x86_64-none\python.exe
+ C:\path\to\prj\AppData\Local\uv\cache\archive-v0\fYwvsebcHXFVIUUYHU9HQ\Scripts\python.exe


----------------------------------------------------------------------
Ran 4 tests in 0.001s

FAILED (failures=1)

The test expecting sys.executable is now skipped in virtual environments.
A new test was added to verify the path returned is under sys.base_prefix.

PS C:\path\to\prj\comtypes> uvx python -m unittest comtypes.test.test_typeinfo.Test_GetModuleFileName -v
test_invalid_handle (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_invalid_handle) ... ok                              
test_invalid_nsize (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_invalid_nsize) ... ok
test_loaded_module_handle (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_loaded_module_handle) ... ok
test_null_handler_sys_base_prefix (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_null_handler_sys_base_prefix) ... ok  
test_null_handler_sys_executable (comtypes.test.test_typeinfo.Test_GetModuleFileName.test_null_handler_sys_executable) ... skipped 'This will fail in a virtual environment.'

----------------------------------------------------------------------
Ran 5 tests in 0.001s

OK (skipped=1)

@junkmd junkmd added the tests enhance or fix tests label Oct 29, 2025
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.70%. Comparing base (fb8fd58) to head (ed2f9e7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #875   +/-   ##
=======================================
  Coverage   84.69%   84.70%           
=======================================
  Files         125      125           
  Lines       11532    11536    +4     
=======================================
+ Hits         9767     9771    +4     
  Misses       1765     1765           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@junkmd junkmd added this to the 1.4.14 milestone Oct 30, 2025
@junkmd junkmd merged commit 6d80cc6 into enthought:main Oct 30, 2025
332 of 346 checks passed
@junkmd junkmd deleted the GetModuleFileName_test branch October 30, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests enhance or fix tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant