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

4.9: pytest is failing in tests/test_mypy.py::MypyRunnerTest::test_run_mypy unit #211

Closed
kloczek opened this issue Dec 6, 2022 · 3 comments

Comments

@kloczek
Copy link

kloczek commented Dec 6, 2022

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-rsa-4.9-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-rsa-4.9-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -q
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.15, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-rsa-version-4.9, configfile: tox.ini
plugins: cov-4.0.0
collected 87 items

tests/test_cli.py ..............                                                                                                                                     [ 16%]
tests/test_common.py .........                                                                                                                                       [ 26%]
tests/test_integers.py ..                                                                                                                                            [ 28%]
tests/test_key.py ......                                                                                                                                             [ 35%]
tests/test_load_save_keys.py ............                                                                                                                            [ 49%]
tests/test_mypy.py F                                                                                                                                                 [ 50%]
tests/test_parallel.py .                                                                                                                                             [ 51%]
tests/test_pem.py .........                                                                                                                                          [ 62%]
tests/test_pkcs1.py .................                                                                                                                                [ 81%]
tests/test_pkcs1_v2.py ...                                                                                                                                           [ 85%]
tests/test_prime.py ....                                                                                                                                             [ 89%]
tests/test_strings.py .                                                                                                                                              [ 90%]
tests/test_transform.py ........                                                                                                                                     [100%]

================================================================================= FAILURES =================================================================================
_______________________________________________________________________ MypyRunnerTest.test_run_mypy _______________________________________________________________________

self = <tests.test_mypy.MypyRunnerTest testMethod=test_run_mypy>

    def test_run_mypy(self):
        proj_root = pathlib.Path(__file__).parent.parent
        args = [
            "--incremental",
            "--ignore-missing-imports",
            f"--python-version={sys.version_info.major}.{sys.version_info.minor}",
        ] + [str(proj_root / dirname) for dirname in test_modules]

        result = mypy.api.run(args)

        stdout, stderr, status = result

        messages = []
        if stderr:
            messages.append(stderr)
        if stdout:
            messages.append(stdout)
        if status:
            messages.append("Mypy failed with status %d" % status)
        if messages and not all("Success" in message for message in messages):
>           self.fail("\n".join(["Mypy errors:"] + messages))
E           AssertionError: Mypy errors:
E           rsa/key.py:68: error: Missing return statement  [empty-body]
E           rsa/key.py:80: error: Missing return statement  [empty-body]
E           rsa/key.py:91: error: Missing return statement  [empty-body]
E           rsa/key.py:98: error: Missing return statement  [empty-body]
E           Found 4 errors in 1 file (checked 28 source files)
E
E           Mypy failed with status 1

tests/test_mypy.py:31: AssertionError

---------- coverage: platform linux, python 3.8.15-final-0 -----------
Name               Stmts   Miss  Cover   Missing
------------------------------------------------
rsa/__init__.py        7      0   100%
rsa/asn1.py            8      0   100%
rsa/cli.py           154      7    95%   73-76, 195-196, 278
rsa/common.py         54      9    83%   166-178
rsa/core.py           20      3    85%   26, 37, 40
rsa/key.py           243     23    91%   135-137, 191, 245, 248, 261, 264, 269, 378, 421, 424, 443, 446, 460, 545, 733, 750, 818, 821, 825-828
rsa/parallel.py       23      4    83%   34-39
rsa/pem.py            50      3    94%   54, 77, 80
rsa/pkcs1.py         117     14    88%   113, 162, 305, 408-417, 432, 440-443
rsa/pkcs1_v2.py       12      0   100%
rsa/prime.py          53      1    98%   83
rsa/randnum.py        30      0   100%
rsa/transform.py      11      0   100%
rsa/util.py           27      4    85%   76-77, 96-97
------------------------------------------------
TOTAL                809     68    92%

========================================================================= short test summary info ==========================================================================
FAILED tests/test_mypy.py::MypyRunnerTest::test_run_mypy - AssertionError: Mypy errors:
====================================================================== 1 failed, 86 passed in 16.66s =======================================================================

Here is list of installed modules in build env

Package                       Version
----------------------------- -----------------
alabaster                     0.7.12
appdirs                       1.4.4
attrs                         22.1.0
Babel                         2.11.0
Brlapi                        0.8.3
build                         0.9.0
charset-normalizer            3.0.1
contourpy                     1.0.6
coverage                      6.5.0
cssselect                     1.1.0
cycler                        0.11.0
distro                        1.8.0
dnspython                     2.2.1
docutils                      0.19
exceptiongroup                1.0.0
extras                        1.0.0
fixtures                      4.0.0
fonttools                     4.38.0
gpg                           1.17.1-unknown
idna                          3.4
imagesize                     1.4.1
importlib-metadata            5.1.0
iniconfig                     1.1.1
Jinja2                        3.1.2
kiwisolver                    1.4.4
libcomps                      0.1.19
louis                         3.23.0
lxml                          4.9.1
MarkupSafe                    2.1.1
matplotlib                    3.6.2
mypy                          0.990
mypy-extensions               0.4.3
numpy                         1.23.1
olefile                       0.46
packaging                     21.3
pbr                           5.9.0
pep517                        0.13.0
Pillow                        9.3.0
pip                           22.3.1
pluggy                        1.0.0
poetry-core                   1.4.0
pyasn1                        0.4.8
Pygments                      2.13.0
PyGObject                     3.42.2
pyparsing                     3.0.9
pytest                        7.2.0
pytest-cov                    4.0.0
python-dateutil               2.8.2
pytz                          2022.4
requests                      2.28.1
rpm                           4.17.0
scour                         0.38.2
setuptools                    65.6.3
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        5.3.0
sphinxcontrib-applehelp       1.0.2.dev20221204
sphinxcontrib-devhelp         1.0.2.dev20221204
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20221204
sphinxcontrib-qthelp          1.0.3.dev20221204
sphinxcontrib-serializinghtml 1.1.5
testtools                     2.5.0
tomli                         2.0.1
typing_extensions             4.4.0
urllib3                       1.26.12
wheel                         0.38.4
zipp                          3.11.0
@myheroyuki
Copy link
Collaborator

I was able to recreate your error by installing the latest version of mypy and running
python3 -m mypy --incremental --ignore-missing-imports rsa/
as is done in the tests. You should be able to resolve it by using the version of mypy specified in pyproject.toml at the moment:
pip3 install mypy=="0.910" --upgrade

However, we should address this issue more meaningfully at some point since we will eventually update the mypy version. I think this can be done with the abstractmethod decorator. I will continue to look at this.

@kloczek
Copy link
Author

kloczek commented Dec 13, 2022

I've alredy added those unite to --deselct list assuming that it must be only test suite issue so .. no rush/take your time 😄
Thank you for the update 👍

@sybrenstuvel
Copy link
Owner

This was fixed in 5045b14, thanks for your report!

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

No branches or pull requests

3 participants