pnuckowski/aioresponses

aiohttp 3.7.4.post0 breaking aioresponses

Closed this issue · 3 comments

The current release of aiohttp is breaking aioresponses:

Traceback (most recent call last):
  File "setup.py", line 88, in <module>
    'Topic :: Utilities'
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/setuptools/__init__.py", line 143, in setup
    return distutils.core.setup(**attrs)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/setuptools/command/test.py", line 228, in run
    self.run_tests()
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/setuptools/command/test.py", line 250, in run_tests
    exit=False,
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/main.py", line 118, in parseArgs
    self._do_discovery(argv[2:])
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/main.py", line 229, in _do_discovery
    self.test = loader.discover(self.start, self.pattern, self.top)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/loader.py", line 341, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/loader.py", line 398, in _find_tests
    full_path, pattern, namespace)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/loader.py", line 475, in _find_test_path
    tests = self.loadTestsFromModule(package, pattern=pattern)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/setuptools/command/test.py", line 54, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "/home/runner/work/tibia.py/tibia.py/tests/tests_client.py", line 5, in <module>
    from aioresponses import aioresponses
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/aioresponses/__init__.py", line 2, in <module>
    from .core import CallbackResult, aioresponses
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/aioresponses/core.py", line 23, in <module>
    from .compat import (
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/aioresponses/compat.py", line 17, in <module>
    AIOHTTP_VERSION = StrictVersion(aiohttp_version)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/distutils/version.py", line 40, in __init__
    self.parse(vstring)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/distutils/version.py", line 137, in parse
    raise ValueError("invalid version number '%s'" % vstring)
ValueError: invalid version number '3.7.4.post0'

Given how the version numbers are actually used, it could be replaced with something as simple as:
AIOHTTP_VERSION = tuple(int(i) for i in aiohttp_version.split(".")[:2])

And used like: if AIOHTTP_VERSION < (3, 4)

Alternatively, given that those versions are rather old, you could just remove the old code and bump the minimum supported version (I mean, who cares if the library doesn't support aiohttp 2.x?).

Same problem, it's second problem with aioresponses I've faced for last two month of its using :\

Thanks for the fast response here! <3