Django

Code

Ticket #3994 (closed: duplicate)

Opened 2 years ago

Last modified 1 year ago

doctest in projects with models split into seperate files not working

Reported by: jesse.lovelace@gmail.com Assigned to: adrian
Milestone: Component: Testing framework
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I've taken over a project with a lot of models and split them into separate files (project/app/models/ModelName.py, etc. and doing the imports in the init.py) and everything works well...except doctest.

My doctests were working with the all-models-in-one-file setup but aren't anymore--unit tests still work though. SVN Django and python 2.4.3.

Attachments

Change History

04/11/07 05:27:49 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • component changed from Core framework to Unit test system.
  • needs_tests changed.
  • needs_docs changed.

Can you please provide an example/test to help us track this down?

04/12/07 10:48:36 changed by jesse.lovelace@gmail.com

Sure, let just let me know what you need as far as specifics, here is a (not so) minimal overall example.

  • Start project 'blah'
  • Start app foo & add to settings.py (and setup your db of course)
  • Enter foo
  • Remove models.py
  • mkdir models
  • Enter foo/models
  • Create file foo/models/Blog.py
    from dhango.db import models
    
    class Blog(models.Model):
        """
        A blog.
    
        >>> b = Blog.objects.create(title="Great post", body="Wow, that was great.")
        >>> b.title=="Great post"
        True
        """
        title = models.CharField(maxlength=50)
        body = models.TextField()
        class Meta:
           app_label='foo'
    

... (spam bot is hating) ...

04/12/07 10:50:30 changed by jesse.lovelace@gmail.com

... continued ...

  • Create file (optionally) foo/models/Comment.py

04/12/07 10:55:25 changed by jesse.lovelace@gmail.com

Ok, I can't get the rest of the example through the spam protection so I'll attach it as a file.

04/12/07 13:48:35 changed by jesse.lovelace@gmail.com

The spam protection is making me a little crazy, I couldn't attach the file with the comment class (and then got blocked on posts per hour) nor give any more code at all. Basically just create a comment model in foo/models/ and then import those in foo/models/init.py then syncdb then test.

07/12/07 10:55:26 changed by russellm

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

Duplicate of #3343.


Add/Change #3994 (doctest in projects with models split into seperate files not working)




Change Properties
Action