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

wheel package contains outdated files - tries to import 'asynctest' #198

Closed
nebularazer opened this issue Feb 2, 2022 · 4 comments
Closed

Comments

@nebularazer
Copy link

nebularazer commented Feb 2, 2022

Hi,
i was trying to use this library but always ended up with an error:

.venv/lib/python3.8/site-packages/respx/mock.py:8: in <module>
    import asynctest
E   ModuleNotFoundError: No module named 'asynctest'

I noticed that the asynctest dependency was already removed in 0.12.0 80ddc31.
The whl contains old files which import asynctest and probably brake the package.

python -m zipfile --list ~/Downloads/respx-0.19.1-py2.py3-none-any.whl
File Name                                             Modified             Size
responsex/__init__.py                          2019-11-15 16:21:26          296
responsex/mock.py                              2019-11-15 16:21:26         7776
responsex/models.py                            2019-11-15 16:21:26         4384
respx/__init__.py                              2021-07-07 11:48:24          756
respx/__version__.py                           2022-01-10 10:09:48           23
respx/api.py                                   2020-11-24 07:45:48         2586
respx/fixtures.py                              2021-07-02 12:33:06          268
respx/handlers.py                              2021-09-15 08:10:26         1245
respx/mock.py                                  2019-11-24 20:28:44        13254
respx/mocks.py                                 2021-11-15 15:37:38        10550
respx/models.py                                2021-11-15 15:24:50        15526
respx/patterns.py                              2022-01-10 10:09:48        17999
respx/plugin.py                                2021-07-05 15:14:04          676
respx/py.typed                                 2019-12-09 08:30:48            0
respx/router.py                                2022-01-10 10:09:48        15119
respx/transports.py                            2021-09-15 08:10:26         2706
respx/types.py                                 2021-07-07 11:48:24         1304
respx-0.19.1.dist-info/LICENSE.md              2022-01-10 10:11:36         1527
respx-0.19.1.dist-info/METADATA                2022-01-10 10:11:36         4039
respx-0.19.1.dist-info/WHEEL                   2022-01-10 10:11:36          110
respx-0.19.1.dist-info/entry_points.txt        2022-01-10 10:11:34           33
respx-0.19.1.dist-info/top_level.txt           2022-01-10 10:11:34            6
respx-0.19.1.dist-info/RECORD                  2022-01-10 10:11:36         1719
  • responsex folder (previous name of this package)
  • respx/mock.py file with the asynctest import - which is not in master

Or am I doing something wrong here?

Steps to reproduce:

python3 -m venv .venv
source .venv/bin/activate
python --version
# Python 3.8.10
which pip3
# /home/myname/Development/thing/.venv/bin/pip3
pip3 install respx
grep asynctest .venv/lib/python3.8/site-packages/respx/mock.py
# import asynctest
#        self._patchers: typing.List[asynctest.mock._patch] = []
#        self.stats = asynctest.mock.MagicMock()
#            patcher = asynctest.mock.patch(target, new=mocker)
#                asynctest.mock.patch.object(
#                    asynctest.mock.patch.object(
#        socket_stream = asynctest.mock.Mock(BaseSocketStream)
@nebularazer
Copy link
Author

I actually found my issue.

In one of my tests i did from respx.mock import HTTPXMock to add a type annotation to have intellisense.
VSCode happily suggested mock after typing respx. as this file really exists and i did not think about it any further.

Removing the import and type annotation solves the main error but i still think these outdated files should not be in the wheel package.

@lundberg
Copy link
Owner

lundberg commented Feb 3, 2022

Wow thanks for noticing @nebularazer!

Fortunately, like you're saying, the old respx/mock.py is not present and used anymore, but for some reason still in the wheel.

@lundberg
Copy link
Owner

lundberg commented Feb 3, 2022

In one of my tests i did from respx.mock import HTTPXMock to add a type annotation to have intellisense. VSCode happily suggested mock after typing respx. as this file really exists and i did not think about it any further.

Great!

Was just about to type that I didn't understood how you (mis)-used respx to trigger the import error, but now I see how. 😅

I'll make a new release with a correct wheel without any legacy stuff, thanks again!

lundberg added a commit that referenced this issue Feb 3, 2022
Fixed
- Better cleanup before building egg, thanks @nebularazer (#198)
@lundberg
Copy link
Owner

lundberg commented Feb 3, 2022

Version 0.19.2 released.

@lundberg lundberg closed this as completed Feb 3, 2022
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

2 participants