Hi,

I have a rather complicated get_absolute_url method in a models.py
file that I wanted to use two doctests to check. Unfortunately the
doctests do not appear to run when I run python manage.py test
according to the verbose output.

Here is the method:

    def get_absolute_url(self):
        """
        Use urlconf to determine url name from page name and then use
url name
        to get absolute url.

        Returns none if there is no url name associated with the page
name.

        Test that homepage works:
        >>> home_fp = Flatpage.objects.get(page_name="Home")
        >>> home_fp.get_absolute_url()
        '/'

        Test that about page works:
        >>> about_fp = Flatpage.objects.get(page_name="About")
        >>> about_fp.get_absolute_url()
        '/about/'
        """
        from django.core.urlresolvers import reverse
        from urls import urlpatterns

        for urlpattern in urlpatterns:
            if (hasattr(urlpattern, "default_args") and
                "page" in urlpattern.default_args and
                urlpattern.default_args["page"] == self.page_name and
                hasattr(urlpattern, "name")):

                return reverse(urlpattern.name)

        return None

And here is the test output:
Installed 6 object(s) from 1 fixture(s)
test_correct_template_loaded
(osl_flatpages.tests.views.OslFlatpageTestCase) ... ok
test_description (osl_flatpages.tests.views.OslFlatpageTestCase) ...
ok
test_existent (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok
test_nonexistent (osl_flatpages.tests.views.OslFlatpageTestCase) ...
ok
test_nontemplate_content
(osl_flatpages.tests.views.OslFlatpageTestCase) ... ok
test_template_content
(osl_flatpages.tests.views.OslFlatpageTestCase) ... ok
test_title (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok

----------------------------------------------------------------------
Ran 7 tests in 0.415s

As you can see, there is no mention of the two doctests being run.

Any ideas as to why the two doctests are not running?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to