Skip to content

QPID-8170: fix qpid-python-test discovery broken by commit 85348b01#18

Merged
jiridanek merged 1 commit intoapache:mainfrom
jiridanek:jd_2023_04_12_fix_broken_test_import
Apr 12, 2023
Merged

QPID-8170: fix qpid-python-test discovery broken by commit 85348b01#18
jiridanek merged 1 commit intoapache:mainfrom
jiridanek:jd_2023_04_12_fix_broken_test_import

Conversation

@jiridanek
Copy link
Copy Markdown
Contributor

The problem stems from the way the testcode imports the production code, so that when both have a module of the same name, the test runner descends into the production code when discovering tests, instead of into the test code.

{code:title=qpid/tests/messaging/__init__.py}
from qpid.tests.messaging.implementation import *

[...]

from . import address, endpoints, message, selector
{code}

The file imported on the first line contains

{code:title=qpid/tests/messaging/implementation.py}
from qpid.messaging import *
{code}

and {{qpid.messaging}} contains its own {{address.py}} submodule.

Therefore, when {{qpid-test-runner}} tries to access {{qpid.tests.messaging.mesage}}, it actually gets {{qpid.messaging.message}}, which was imported first. But that does not contain any tests, and the message tests are missed and never executed.

This only started happening after my relative imports modernizing commit 9651001.

Before, Totals: 349 tests, 349 passed, 0 skipped, 0 ignored, 0 failed and Totals: 678 tests, 585 passed, 93 skipped, 0 ignored, 0 failed (https://github.com/apache/qpid-python/actions/runs/4661323947/jobs/8250463871)

After, Totals: 218 tests, 218 passed, 0 skipped, 0 ignored, 0 failed and Totals: 547 tests, 454 passed, 93 skipped, 0 ignored, 0 failed (https://github.com/apache/qpid-python/actions/runs/4661535006/jobs/8250915935)

The problem stems from the way the testcode imports the production code, so that when both have a module of the same name, the test runner descends into the production code when discovering tests, instead of into the test code.

```
{code:title=qpid/tests/messaging/__init__.py}
from qpid.tests.messaging.implementation import *

[...]

from . import address, endpoints, message, selector
{code}

The file imported on the first line contains

{code:title=qpid/tests/messaging/implementation.py}
from qpid.messaging import *
{code}
```

and {{qpid.messaging}} contains its own {{address.py}} submodule.

Therefore, when {{qpid-test-runner}} tries to access {{qpid.tests.messaging.mesage}}, it actually gets {{qpid.messaging.message}}, which was imported first. But that does not contain any tests, and the message tests are missed and never executed.

This only started happening after my relative imports modernizing commit apache@9651001.

Before, Totals: 349 tests, 349 passed, 0 skipped, 0 ignored, 0 failed and Totals: 678 tests, 585 passed, 93 skipped, 0 ignored, 0 failed (https://github.com/apache/qpid-python/actions/runs/4661323947/jobs/8250463871)

After, Totals: 218 tests, 218 passed, 0 skipped, 0 ignored, 0 failed and Totals: 547 tests, 454 passed, 93 skipped, 0 ignored, 0 failed (https://github.com/apache/qpid-python/actions/runs/4661535006/jobs/8250915935)
@jiridanek
Copy link
Copy Markdown
Contributor Author

>>> 678-349
329

So the total test count is correct, albeit the second command runs less tests because it now does not run again what was run in the first command.

$ python2 qpid-python-test -l | wc
    349     349   19741
$ python2 qpid-python-test -l -m qpid_tests | wc
    329     329   22640
$ python2 qpid-python-test -l -m qpid_tests -m qpid.tests | wc
    678     678   42381

All tests accounted for.

@jiridanek jiridanek merged commit 71171f7 into apache:main Apr 12, 2023
@jiridanek jiridanek deleted the jd_2023_04_12_fix_broken_test_import branch April 12, 2023 19:49
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.

1 participant