From 7853e629cae426b95bd13ec95ab1db1213d66be7 Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Wed, 28 Mar 2018 00:46:41 +0300 Subject: [PATCH] Add test for #144 --- ...al_model_utils_noerror_override_manager.py | 3 ++- .../tests/input/func_noerror_model_objects.py | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 pylint_django/tests/input/func_noerror_model_objects.py diff --git a/pylint_django/tests/input/external_model_utils_noerror_override_manager.py b/pylint_django/tests/input/external_model_utils_noerror_override_manager.py index b58cc163..b8e79a7d 100644 --- a/pylint_django/tests/input/external_model_utils_noerror_override_manager.py +++ b/pylint_django/tests/input/external_model_utils_noerror_override_manager.py @@ -1,6 +1,7 @@ # Check that when overriding the 'objects' attribite of a model class # with a manager from the django-model-utils package pylint-django -# does not report not-an-iterator error +# does not report not-an-iterator error, see +# https://github.com/PyCQA/pylint-django/issues/117 # pylint: disable=missing-docstring from model_utils.managers import InheritanceManager diff --git a/pylint_django/tests/input/func_noerror_model_objects.py b/pylint_django/tests/input/func_noerror_model_objects.py new file mode 100644 index 00000000..5cf27245 --- /dev/null +++ b/pylint_django/tests/input/func_noerror_model_objects.py @@ -0,0 +1,20 @@ +# Test that defining `objects` as a regular model manager +# doesn't raise issues, see +# https://github.com/PyCQA/pylint-django/issues/144 +# +# pylint: disable=missing-docstring + +from django.db import models + + +class ModelWithRegularManager(models.Model): + objects = models.Manager() + + name = models.CharField() + + +def function(): + record = ModelWithRegularManager.objects.all()[0] + + for record in ModelWithRegularManager.objects.all(): + print(record.name)