Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace some relative imports in tests #1985

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

opoplawski
Copy link
Contributor

I was getting some errors in the tests about relative imports.

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution.

There's probably many more relative imports in the codebase, but it usually isn't an issue. I'm curious what issue you were seeing, so we can avoid it in the future.

@corranwebster corranwebster merged commit ce8b285 into enthought:main Feb 1, 2023
@opoplawski
Copy link
Contributor Author

+ export PYTHONPATH=/home/orion/BUILDROOT/python-traitsui-7.4.3-3.fc38.x86_64/usr/lib/python3.11/site-packages
+ PYTHONPATH=/home/orion/BUILDROOT/python-traitsui-7.4.3-3.fc38.x86_64/usr/lib/python3.11/site-packages
+ export PYTHONUNBUFFERED=1
+ PYTHONUNBUFFERED=1
+ pushd build/lib/traitsui/tests/
~/fedora/python-traitsui/traitsui-7.4.3/build/lib/traitsui/tests ~/fedora/python-traitsui/traitsui-7.4.3
+ PYTHONPATH=/home/orion/BUILDROOT/python-traitsui-7.4.3-3.fc38.x86_64/usr/lib/python3.11/site-packages
+ xvfb-run /usr/bin/python3 -X faulthandler -W default -m unittest discover -v
/usr/lib64/python3.11/site-packages/traits/observation/_generated_parser.py:258: DeprecationWarning: module 'sre_parse' is deprecated
  import sre_parse
/usr/lib64/python3.11/site-packages/traits/observation/_generated_parser.py:259: DeprecationWarning: module 'sre_constants' is deprecated
  import sre_constants
/usr/lib64/python3.11/site-packages/shiboken2/files.dir/shibokensupport/feature.py:139: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
  return original_import(name, *args, **kwargs)
...
ERROR: test_key_bindings (unittest.loader._FailedTest.test_key_bindings)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_key_bindings
Traceback (most recent call last):
  File "/usr/lib64/python3.11/unittest/loader.py", line 407, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 350, in _get_module_from_name
    __import__(name)
  File "/usr/lib64/python3.11/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/orion/fedora/python-traitsui/traitsui-7.4.3/build/lib/traitsui/tests/test_key_bindings.py", line 17, in <module>
    from ..key_bindings import KeyBinding, KeyBindings, KeyBindingsHandler
  File "/usr/lib64/python3.11/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: attempted relative import with no known parent package


======================================================================
ERROR: test_view_application (unittest.loader._FailedTest.test_view_application)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_view_application
Traceback (most recent call last):
  File "/usr/lib64/python3.11/unittest/loader.py", line 407, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 350, in _get_module_from_name
    __import__(name)
  File "/usr/lib64/python3.11/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/orion/fedora/python-traitsui/traitsui-7.4.3/build/lib/traitsui/tests/test_view_application.py", line 17, in <module>
    from ._tools import (
  File "/usr/lib64/python3.11/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: attempted relative import with no known parent package

@corranwebster
Copy link
Contributor

Ah, it's under Python 3.11 - that's why we haven't been seeing it. We haven't yet really put any effort into fixing things for Python 3.11 - I know that there are some issues with Pyface, so this is likely not the only issue you'll see on 3.11, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants