jazzband / django-defender

A simple super fast django reusable app that blocks people from brute forcing login attempts
Apache License 2.0
1.04k stars 142 forks source link

AttributeError: module 'mockredis' has no attribute 'mock_strict_redis_client' #158

Open Hamza-Lachi opened 4 years ago

Hamza-Lachi commented 4 years ago

I Run This Command

from your documantation to check is it working correctly

PYTHONPATH=$PYTHONPATH:$PWD django-admin.py test defender --settings=defender.test_settings

but i always get this issue:

Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/test.py", line 53, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python3.7/dist-packages/django/test/runner.py", line 687, in run_tests
    self.run_checks()
  File "/usr/local/lib/python3.7/dist-packages/django/test/runner.py", line 625, in run_checks
    call_command('check', verbosity=self.verbosity)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 168, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/check.py", line 64, in handle
    fail_level=getattr(checks, options['fail_level']),
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 395, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 382, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.7/dist-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.7/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/lib/python3.7/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/usr/local/lib/python3.7/dist-packages/django/urls/resolvers.py", line 407, in check
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.7/dist-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/dist-packages/django/urls/resolvers.py", line 588, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.7/dist-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/dist-packages/django/urls/resolvers.py", line 581, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/lenovo/.local/lib/python3.7/site-packages/defender/test_urls.py", line 4, in <module>
    from .urls import urlpatterns as original_urlpatterns
  File "/home/lenovo/.local/lib/python3.7/site-packages/defender/urls.py", line 2, in <module>
    from .views import block_view, unblock_ip_view, unblock_username_view
  File "/home/lenovo/.local/lib/python3.7/site-packages/defender/views.py", line 10, in <module>
    from .utils import get_blocked_ips, get_blocked_usernames, unblock_ip, unblock_username
  File "/home/lenovo/.local/lib/python3.7/site-packages/defender/utils.py", line 20, in <module>
    REDIS_SERVER = get_redis_connection()
  File "/home/lenovo/.local/lib/python3.7/site-packages/defender/connection.py", line 24, in get_redis_connection
    return mockredis.mock_strict_redis_client()  # pragma: no cover
AttributeError: module 'mockredis' has no attribute 'mock_strict_redis_client'

python == Python 3.7.5 django == Django 3.0.5

kencochrane commented 4 years ago

What version of mockredis do you have installed?

kencochrane commented 4 years ago

@Hamza-Lachi is this still an issue? If not, I'm going to close.

NMelis commented 4 years ago

I also catch this exception :( mockredis==0.1.3dev Django==2.2.1 Python 3.8.2

NMelis commented 4 years ago

Oops... I loser! I installed mockredis. But need mockredispy