Django

Code

Ticket #2848 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] CommentManager doctest is broken.

Reported by: Maximillian Dornseif <md@hudora.de> Assigned to: adrian
Milestone: Component: Contrib apps
Version: SVN Keywords: cache win32 linux freebsd
Cc: md@hudora.de Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

It seems to me that a docstring in the comment model is broken - it can't wor without instantating an object. And this resultet in python manage.py test failing for my project. See below for the exact error. Since the comment system is meant to be rewritten I spent no time further investigating the issue but just disabled the docstring like this:

+++ django/contrib/comments/models.py   (working copy)
     def get_rating_options(self, rating_string):
[...]
-        >>> s = "scale:1-10|First_category|Second_category"
-        >>> get_rating_options(s)
+        >> s = "scale:1-10|First_category|Second_category"
+        >> get_rating_options(s)

(full patch at http://c0re.23.nu/c0de/misc/django-3884-comment_doctests.py#)

Error message:

======================================================================
FAIL: Doctest: django.contrib.comments.models.CommentManager.get_rating_options
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/test/doctest.py", line 2156, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for django.contrib.comments.models.CommentManager.get_rating_options
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/comments/models.py", line 33, in get_rating_options

----------------------------------------------------------------------
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/comments/models.py", line 37, in django.contrib.comments.models.CommentManager.get_rating_options
Failed example:
    get_rating_options(s)
Exception raised:
    Traceback (most recent call last):
      File "/private/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/test/doctest.py", line 1243, in __run
        compileflags, 1) in test.globs
      File "<doctest django.contrib.comments.models.CommentManager.get_rating_options[1]>", line 1, in ?
        get_rating_options(s)
    NameError: name 'get_rating_options' is not defined

Attachments

comment_test.diff (0.6 kB) - added by pb@e-scribe.com on 10/09/06 07:38:56.
quick patch to fix doctest
django-comment-doctest.diff (0.6 kB) - added by dummy@habmalnefrage.de on 10/28/06 04:08:52.
This fixes the doctest, the other patch file disables the doctest

Change History

10/09/06 07:38:29 changed by pb@e-scribe.com

I ran into this problem today and wrote a quick patch before coming across this ticket. I'll attach it, FWIW.

10/09/06 07:38:56 changed by pb@e-scribe.com

  • attachment comment_test.diff added.

quick patch to fix doctest

10/09/06 11:46:39 changed by pb@e-scribe.com

  • keywords set to cache win32 linux freebsd.
  • priority changed from low to normal.

Changing priority to Normal

10/28/06 04:08:52 changed by dummy@habmalnefrage.de

  • attachment django-comment-doctest.diff added.

This fixes the doctest, the other patch file disables the doctest

11/05/06 16:33:50 changed by verbosus

I’ve just been bitten by this bug as well: basically whenever I run python manage.py test on my project (that includes the comments app) the comments get tested and my test suite fails.

11/06/06 23:20:00 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

(In [4049]) Fixed #2848: broken doctest in comment app. Thanks, dummy@habmalnefrage.de


Add/Change #2848 ([patch] CommentManager doctest is broken.)




Change Properties
Action