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

stestr run --pdb doesn't work for relative imports #288

Open
mtreinish opened this issue Jan 16, 2020 · 0 comments
Open

stestr run --pdb doesn't work for relative imports #288

mtreinish opened this issue Jan 16, 2020 · 0 comments
Labels

Comments

@mtreinish
Copy link
Owner

Issue description

When running tests with the --pdb flag for tests in a directory that are relative imports are not working. For example if the tests are not included in the source of the project under test (ie a separate top level test/ directory). For example:

{0} unittest.loader._FailedTest.python [0.000093s] ... FAILED

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
    ImportError: Failed to import test module: python
    Traceback (most recent call last):
      File "/usr/lib64/python3.7/unittest/loader.py", line 154, in loadTestsFromName
        module = __import__(module_name)
    ModuleNotFoundError: No module named 'test.python'
    
    

==============================
Failed 1 tests - output below:
==============================

unittest.loader._FailedTest.python
----------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
    ImportError: Failed to import test module: python
    Traceback (most recent call last):
      File "/usr/lib64/python3.7/unittest/loader.py", line 154, in loadTestsFromName
        module = __import__(module_name)
    ModuleNotFoundError: No module named 'test.python'
    

No discover, which uses a subprocess works fine. My guess is that the python interpreter doesn't have the test/ in it's pythonpath for whatever reason and can't find the module from the test id, but the source of the issue is not clear.

Expected behavior and actual behavior

The test case is run in the same process (ie pdb mode) instead of erroring.

Steps to reproduce the problem

Try to run any test case from https://github.com/Qiskit/qiskit-terra with the --pdb flag

Specifications like the version of the project, operating system, or hardware

System information

  • OS: [e.g. Windows10, openSUSE 15.1, Ubuntu 18.04] Arch linux
  • stestr version (stestr --version): 2.6.0 (and master)
  • Python release (python --version): 3.7
  • pip packages (pip freeze): N/A

Additional information

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

No branches or pull requests

1 participant