Re: Mypy-django: Enable static type checking in your django projects

2016-10-14 Thread Jari Pennanen
Hello!

This is awesome, I stopped using Django ~4 years ago, because type safety 
is something I think is necessity in bigger projects.

Why is this a separate repo? Shouldn't this be the project for Django devs? 
I cannot consider Django again until type-safety (in API / models level at 
least) is part of the ethos of main developers.

Sad fact is that right now my frontend stack is more durable (TypeScript + 
React which type checks even templates) than backend if I were to use 
Django without types.

Thanks.

On Thursday, October 6, 2016 at 7:51:12 PM UTC+3, Elías Andrawos wrote:
>
>
> Hi all, 
> We’re happy to make a release of mypy-django 0.1.1, the first of many!
> It’s a collection of type stubs for using with the mypy static type 
> checking tool (and also with other PEP-484 compliant tools). 
>
> more info;
> http://www.machinalis.com/blog/first-release-of-mypy-django/ 
> 
> https://github.com/machinalis/mypy-django
>
> Feedback is welcome, thanks in advance
>
> Elías
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20da19d8-208a-4dc2-94f6-7d84e19d074c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GROUP BY fields appearance, bug or feature?

2011-01-16 Thread Jari Pennanen
Here is my problem as using powerful raw,

User.objects.raw('SELECT usr.*, em.added as latest_email_added,
em.success as latest_email_success, em.subject as latest_email_subject
FROM auth_user AS usr LEFT JOIN dmusic_useremail as em ON em.user_id =
usr.id GROUP BY usr.id HAVING Max(em.added)')

That shall be good enough for me, it seems to be Sqlite3 and MySQL
compatible SQL (which is just right for my app)

On Jan 16, 11:53 am, Jari Pennanen  wrote:
> Hi!
>
> Suppose following model:
>
> class UserEmail(models.Model):
>     """User email"""
>
>     user = models.ForeignKey(User, db_index=True,
>                              null=True, blank=True, editable=False)
>     """User recieving the email"""
>
>     added = models.DateTimeField(_("added"), auto_now_add=True)
>     """Added to database"""
>
>     subject = models.CharField(_('subject'), max_length=128)
>     """Subject"""
>
>     message = models.TextField(_('message'))
>     """Message"""
>
> How can I retrieve list of users and their latest email subject?
>
> This almost works:
>
> User.objects.all()\
>   .annotate(latest_email_added=Max('useremail__added'))
>
> But it does not give me the other fields of latest email such as
> subject, so I try to add other fields using extra:
> User.objects.all()\
>   .annotate(latest_email_added=Max('useremail__added'))\
>   .extra(select={'email_subject' : 'myapp_useremail.subject'})
>
> Suddenly it adds a GROUP BY to the query with a long list of fields
> that should not be there, which breaks everything, now I get multiple
> rows per user which is not wanted.
>
> If I try to modify the group_by manually, like this:
> a = User.objects.all()\
>   .annotate(latest_email_added=Max('useremail__added'))\
>   .extra(select={'email_subject' : 'dmusic_useremail.subject'});
> a.query.group_by = [('auth_user', 'id')];
> print a.query
>
> There is still one extra field in group by making it break:
> ... GROUP BY "auth_user"."id", (dmusic_useremail.subject)
>
> Can someone elaborate this behavior?
>
> Any help is appreciated, thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



Re: GROUP BY fields appearance, bug or feature?

2011-01-16 Thread Jari Pennanen
User != UserEmail

User does not have subject, thus it will raise AttributeError: 'User'
object has no attribute 'subject'

Secondly, I do not want to create 1+N queries (where N is number of
users), with creating a query per user this would be simple but very
inefficient.

On Jan 16, 12:16 pm, Praveen Krishna R 
wrote:
> *First of all did you try accessing the email subject with a dotted
> notation?*
> try
> u = User.objects.all()
> and
> u[0].subject
>
> On Sun, Jan 16, 2011 at 12:53 PM, Jari Pennanen 
> wrote:
>
>
>
>
>
>
>
>
>
> > Hi!
>
> > Suppose following model:
>
> > class UserEmail(models.Model):
> >    """User email"""
>
> >    user = models.ForeignKey(User, db_index=True,
> >                             null=True, blank=True, editable=False)
> >    """User recieving the email"""
>
> >    added = models.DateTimeField(_("added"), auto_now_add=True)
> >    """Added to database"""
>
> >    subject = models.CharField(_('subject'), max_length=128)
> >    """Subject"""
>
> >    message = models.TextField(_('message'))
> >    """Message"""
>
> > How can I retrieve list of users and their latest email subject?
>
> > This almost works:
>
> > User.objects.all()\
> >  .annotate(latest_email_added=Max('useremail__added'))
>
> > But it does not give me the other fields of latest email such as
> > subject, so I try to add other fields using extra:
> > User.objects.all()\
> >  .annotate(latest_email_added=Max('useremail__added'))\
> >  .extra(select={'email_subject' : 'myapp_useremail.subject'})
>
> > Suddenly it adds a GROUP BY to the query with a long list of fields
> > that should not be there, which breaks everything, now I get multiple
> > rows per user which is not wanted.
>
> > If I try to modify the group_by manually, like this:
> > a = User.objects.all()\
> >  .annotate(latest_email_added=Max('useremail__added'))\
> >  .extra(select={'email_subject' : 'dmusic_useremail.subject'});
> > a.query.group_by = [('auth_user', 'id')];
> > print a.query
>
> > There is still one extra field in group by making it break:
> > ... GROUP BY "auth_user"."id", (dmusic_useremail.subject)
>
> > Can someone elaborate this behavior?
>
> > Any help is appreciated, thanks!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> *Praveen Krishna R*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



GROUP BY fields appearance, bug or feature?

2011-01-16 Thread Jari Pennanen
Hi!

Suppose following model:

class UserEmail(models.Model):
"""User email"""

user = models.ForeignKey(User, db_index=True,
 null=True, blank=True, editable=False)
"""User recieving the email"""

added = models.DateTimeField(_("added"), auto_now_add=True)
"""Added to database"""

subject = models.CharField(_('subject'), max_length=128)
"""Subject"""

message = models.TextField(_('message'))
"""Message"""

How can I retrieve list of users and their latest email subject?

This almost works:

User.objects.all()\
  .annotate(latest_email_added=Max('useremail__added'))

But it does not give me the other fields of latest email such as
subject, so I try to add other fields using extra:
User.objects.all()\
  .annotate(latest_email_added=Max('useremail__added'))\
  .extra(select={'email_subject' : 'myapp_useremail.subject'})

Suddenly it adds a GROUP BY to the query with a long list of fields
that should not be there, which breaks everything, now I get multiple
rows per user which is not wanted.

If I try to modify the group_by manually, like this:
a = User.objects.all()\
  .annotate(latest_email_added=Max('useremail__added'))\
  .extra(select={'email_subject' : 'dmusic_useremail.subject'});
a.query.group_by = [('auth_user', 'id')];
print a.query

There is still one extra field in group by making it break:
... GROUP BY "auth_user"."id", (dmusic_useremail.subject)

Can someone elaborate this behavior?

Any help is appreciated, thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



Splitting tests.py to package

2010-11-05 Thread Jari Pennanen
I've been trying to split tests.py, but I've noticed that models
defined inside test module does not work. Normally one can define
models in tests.py like this:

class JSONFieldModel(models.Model):
json = JSONField()

class JSONFieldTest(TestCase):
def setUp(self):
pass

def test_json_serialization(self):
"""JSONField serialization"""
thedata = {'test': 5}

jsdb = JSONFieldModel(json=thedata)
jsdb.save()
del jsdb

jsdb = JSONFieldModel.objects.get(pk=1)
self.failUnlessEqual(thedata, jsdb.json,
 'JSON Serialization mismatch')

And they are created to test database just fine. But when I split the
tests.py to package and have tests/__init__.py import all, it throws
me error of not having database tables. Tests do start just fine, but
these models are not apparently created.

Is there any good workaround for this? I really like the idea of
splitting long tests.py to logical modules.

-- 
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.



RegexURLPattern that matched of a specific HttpRequest?

2010-07-29 Thread Jari Pennanen
Hi!

I'm doing app that needs to list all urlconf patterns, thats easy,
just looping and flattening the includes inside urlpatterns of current
settings urlconf. But, the hard part is that I also need to know which
one is the current RegexURLPattern of executed view (specific
request's RegexURLPattern)?

I've tried to implement Middleware but there doesn't seem to be easy
way to get "current RegexURLPattern" of the request.

One way would probably be of re-resolving the URL in the request, but
that is unnecessary duplication since Django did that already because
it got to the view.

Any ideas? Any help is appreciated, thanks!

-- 
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.



Re: Javascript string catalogs (jsi18n) - accessing strings in project/locale?

2010-07-12 Thread Jari Pennanen
Hi, I know this comes late, but for the future reference:

My problem was that I had "locale" directory in *project* directory,
"myproject/locale" but I didn't have myproject in INSTALLED_APPS.

So the thing that contains localization strings *must* be ALSO in the
INSTALLED_APPS = [..., 'myproject']

On 8 kesä, 16:13, Stodge  wrote:
> I ran makemessages -d djangojs from my project level directory, and
> Django automatically generated the .po file in project/locale/. I
> followed the documentation (and the book The Definitive Guide to
> Django) but I cannot access these translated strings. The catalog is
> always empty. My urls contains:
>
> js_info_dict = {
>         'packages': ('django.conf',),
>
> }
>
> But this doesn't work. I tried:
>
> js_info_dict = {
>         'packages': ('project_name',),
>
> }
>
> As this is package name for the project directory, but no dice. So how
> do I access the strings in my project directory?
>
> Thanks

-- 
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.



Re: Access Foreignkey ID without doing query? (Merging Foreignkey/M2M) (manual select_related)

2010-07-12 Thread Jari Pennanen
Uhh, you are right... it does work!

I though I was writing a pseudo code (without testing that my pseudo
code indeed worked already)... Sometimes Django is intuitive to extent
it guesses what I wanted!

Though foreignkey documentation did not include information that I can
access the raw ID like "host_id".

And BTW I ended up using dict to cache the ID's myself too.

On 12 heinä, 15:21, Daniel Roseman  wrote:
> On Jul 12, 11:29 am, Jari Pennanen  wrote:
>
>
>
>
>
> > Hi!
>
> > Is it possible to access the foreignkey ID value of model? I do not
> > want Django ORM to try to make query because it fails in this case. I
> > have exact same problem 
> > ashttp://groups.google.com/group/django-users/browse_thread/thread/d24f...
> > (though I'm not using admin, I have list view of my own)
>
> > I will use the same example:
>
> > Host
> >     name = CharField
> > Account
> >     name = CharField
> >     host = ForeignKey(Host, related_name='accounts')
>
> > I have list of "Host" where I need to also list on each item a list of
> > accounts. Now if I could access the raw "Account.host" foreignkey ID I
> > could do this in two queries:
>
> > hosts = list(Host.objects.all())
> > accounts = list(Account.objects.filter(host__in=hosts))
>
> > for h in hosts:
> >   h.account_list = [a for a in accounts if a.host_id == h.id] #
> > NOTICE: THIS is not possible! I cannot access the foreignkey host_id :
> > (
>
> Why not? What happens? This is the correct way to access the foreign
> key ID.
>
> Note that if you get this working, you'll be iterating through all the
> selected accounts each time, for every Host. If you've got large
> numbers of accounts, there is a slightly more efficient way of doing
> this, by using dictionaries to pre-group the accounts by their
> matching hosts: see my blog[1] for an explanation.
> --
> DR.
>
> [1]:http://blog.roseman.org.uk/2010/01/11/django-patterns-part-2-efficien...

-- 
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.



Access Foreignkey ID without doing query? (Merging Foreignkey/M2M) (manual select_related)

2010-07-12 Thread Jari Pennanen
Hi!

Is it possible to access the foreignkey ID value of model? I do not
want Django ORM to try to make query because it fails in this case. I
have exact same problem as 
http://groups.google.com/group/django-users/browse_thread/thread/d24f2a502da3171c?pli=1
(though I'm not using admin, I have list view of my own)

I will use the same example:

Host
name = CharField
Account
name = CharField
host = ForeignKey(Host, related_name='accounts')

I have list of "Host" where I need to also list on each item a list of
accounts. Now if I could access the raw "Account.host" foreignkey ID I
could do this in two queries:

hosts = list(Host.objects.all())
accounts = list(Account.objects.filter(host__in=hosts))

for h in hosts:
  h.account_list = [a for a in accounts if a.host_id == h.id] #
NOTICE: THIS is not possible! I cannot access the foreignkey host_id :
(

-- 
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.



django.test.TestCase in external tests files (KeyError: 'SUPPORTS_TRANSACTIONS'")

2010-07-01 Thread Jari Pennanen
Hi,

I'm trying to use django.test.TestCase class in my project's directory
"tests", e.g.

myapp/models.py
myapp/...
tests/sometest.py

If I use django TestCase inside sometest.py I get:

Traceback (most recent call last):
  File "\django\django\test\testcases.py", line 256, in __call__
self._pre_setup()
  File "\django\django\test\testcases.py", line 223, in _pre_setup
self._fixture_setup()
  File "\django\django\test\testcases.py", line 486, in _fixture_setup
if not connections_support_transactions():
  File "\django\django\test\testcases.py", line 475, in
connections_support_transactions
for conn in connections.all())
  File "\django\django\test\testcases.py", line 475, in 
for conn in connections.all())
KeyError: 'SUPPORTS_TRANSACTIONS'

But if I use it normally in the "myapp/tests.py", and command
"manage.py test myapp" it works just fine. Whats the problem here? I
would prefer to keep my tests outside the main package, and run them
manually without the manage.py (actually Eclipse runs tests directory
tests automatically).

My testing file currently is pretty simple:

from django.test import TestCase

class SomeTestCase(TestCase):
def test_something(self):
pass

Thanks.

-- 
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.



After sync signal?

2010-07-01 Thread Jari Pennanen
Hi!

I'm trying to add rows to database after sync, but I need to do it
after *all* of the apps has been synced. Since my after sync function
traverses all these apps and builds interesting information to the
database.

While post_syncdb http://docs.djangoproject.com/en/dev/ref/signals/#post-syncdb
allows to connect to sender, I need to know is there a way to connect
to "last sender"... Since there isn't any kind of "after sync signal".

Thanks.

-- 
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.



Re: Unit testing Templatetags

2010-02-07 Thread Jari Pennanen
Hey!

Thanks a lot, that seems obvious now...

I found out that doing this:

template.libraries['django.templatetags.mytest'] = register

I can then use {% load mytest %} ... for the tags.

On 7 helmi, 22:19, Rolando Espinoza La Fuente 
wrote:
> You can see example code 
> here:http://github.com/darkrho/django-dummyimage/blob/master/dummyimage/te...
Great example.

IMO, there should be more unit-testing examples in Django
documentation, templatetags should be one...

-- 
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.



Unit testing Templatetags

2010-02-07 Thread Jari Pennanen
Hi!

I decided to try to unit test templatetag using following code:

import unittest
from django import template
from django.template import loader

register = template.Library()

@register.simple_tag
def sometag(arg=None):
return "ok"


class MyTagTests(unittest.TestCase):
def setUp(self):
self.context = template.Context()

def test_sometag(self):
"""Test the tag"""

template_content = """
{% sometag "some string" %}
"""

#print
loader.get_template_from_string(template_content).render(self.context)
print
template.Template(template_content).render(self.context)


if __name__ == '__main__':
unittest.main()

But I keep getting "TemplateSyntaxError: Invalid block tag: 'sometag'"

As a reference I've been looking on to this
http://code.djangoproject.com/browser/django/trunk/tests/othertests/templates.py?rev=3113
only difference I can see is the test_template_loader() function, but
is that it? I should also do template_loader to get the tag tests? I
would like to know what is the simplest way to do this, there got to
be a way to test these without custom template loader...

-- 
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.



Re: Cycle tag must be in same template, why? Any options?

2009-05-31 Thread Jari Pennanen

I found the culprit,

http://code.djangoproject.com/svn/django/trunk/django/template/defaulttags.py
line 507:
"if not hasattr(parser, '_namedCycleNodes'):"
Parser is template specific, but making cycle not work is stupid since
I noticed something else too, the variable *is* passed to included
template but not the knowledge how to cycle it. Thus this is possible:

list.html:

...
{% include "list_item.html" %}
...

list_item.html
{{ rowcolors }}

That does work, but it won't cycle as one could expect.

I'm now trying to found a way to make it cycle in included template
too.

On 31 touko, 13:52, Jari Pennanen  wrote:
> Hi!
>
> Is there reason why cycle must be in the *same* template, and not for
> instance in parent template? There are usecases:
>
> list.html:
> {% cycle 'row1' 'row2' as rowcolors %}
> 
> 
>   ..
>   ..
>   ..
> 
> {% for item in object_list %}
>   {% include "list_item.html" %}
> {% endfor %}
> 
>
> list_item.html:
> 
>   ..
>   ..
>   ..
> 
>
> Throws the error that rowcolors is not defined, meaning it won't get
> passed to list_item.html.
>
> Use case:
>
> For obvious reasons one cannot but the rowcolors inside list_item.html
> since there can be list.html that implements multiple loops etc, like
> this:
> complicated_list.html:
> {% cycle 'row1' 'row2' as rowcolors %}
> 
> 
>   ..
>   ..
>   ..
> 
> {% for item in object_list %}
>   {% include "list_item.html" %}
> {% endfor %}
> ...
> {% for item in object_list_highlighted %}
>   {% include "list_item.html" %}
> {% endfor %}
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Cycle tag must be in same template, why? Any options?

2009-05-31 Thread Jari Pennanen

Hi!

Is there reason why cycle must be in the *same* template, and not for
instance in parent template? There are usecases:

list.html:
{% cycle 'row1' 'row2' as rowcolors %}


  ..
  ..
  ..

{% for item in object_list %}
  {% include "list_item.html" %}
{% endfor %}


list_item.html:

  ..
  ..
  ..


Throws the error that rowcolors is not defined, meaning it won't get
passed to list_item.html.

Use case:

For obvious reasons one cannot but the rowcolors inside list_item.html
since there can be list.html that implements multiple loops etc, like
this:
complicated_list.html:
{% cycle 'row1' 'row2' as rowcolors %}


  ..
  ..
  ..

{% for item in object_list %}
  {% include "list_item.html" %}
{% endfor %}
...
{% for item in object_list_highlighted %}
  {% include "list_item.html" %}
{% endfor %}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Re: Finding Reason for Form.is_valid()

2009-04-29 Thread Jari Pennanen

Remember to check also: form.non_field_errors

On Apr 29, 11:59 pm, Ayaz Ahmed Khan  wrote:
> On 28-Apr-09, at 8:35 PM, Margie wrote:
>
> > I often put a break point using pdb
>
> > import pdb
> > pdb.set_trace()
>
> > This  causes the server (assuming you are using the django
> > development server) to drop to the pdb prompt when it hits the
> > set_trace().
>
> > Then I just print the form and look at the output.
>
> Oh, that's lovely, indeed. The thought of using the debugger never
> crossed my mind. The OP may or may not have had a slightly different
> requirement than mine, but for me the task of debugging a problem when
> writing unit tests and subsequently the views being tested, may become
> daunting. I could always drop to an interactive shell, instantiate
> objects and inspect their contents and stuff, but the alternative to
> use pdb the way you have suggested is much, much better and more
> convenient.
>
> --
> Ayaz Ahmed Khan
>
> You might have mail.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Re: doctest testing with templatefilters

2009-04-23 Thread Jari Pennanen

Found out that putting them to tests.py *does* run them, but since
when all is "ok" it won't print anything... But nevertheless I
wouldn't like to put them root, and inside "if __name__ ==
'__main__':", manage.py test myapp wont find them.

On Apr 23, 8:11 pm, Jari Pennanen  wrote:
> Hi!
>
> I'm just wondering the same thing, not exact same, but this:
>
> How do I run doctests when doing "./manage.py test myapp", where
> should I define doctest.testmod(...) lines? In root of tests.py it
> doesn't work.
>
> On Apr 12, 7:51 pm, Julian  wrote:
>
> > hello,
>
> > I am testing some of my filters with doctests. it's very easy, but I
> > have to call the module with the filters manually:
>
> > python /foo/bar/templatetags/eggs_extra.py -v
>
> > to let the doctest run.
>
> > Now I've added at the end of the egg.py the following code:
>
> > def run_doctest():
> >     import doctest
> >     doctest.testmod()
>
> > and at the beginning of the tests.py the following:
>
> > from foo/bar/templatetags/eggs_extra.py import run_doctest
>
> > run_doctest()
>
> > but nothing happens.
>
> > what can I do that that the doctests in the template filters are run
> > with ./manage.py test?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Re: doctest testing with templatefilters

2009-04-23 Thread Jari Pennanen

Hi!

I'm just wondering the same thing, not exact same, but this:

How do I run doctests when doing "./manage.py test myapp", where
should I define doctest.testmod(...) lines? In root of tests.py it
doesn't work.

On Apr 12, 7:51 pm, Julian  wrote:
> hello,
>
> I am testing some of my filters with doctests. it's very easy, but I
> have to call the module with the filters manually:
>
> python /foo/bar/templatetags/eggs_extra.py -v
>
> to let the doctest run.
>
> Now I've added at the end of the egg.py the following code:
>
> def run_doctest():
>     import doctest
>     doctest.testmod()
>
> and at the beginning of the tests.py the following:
>
> from foo/bar/templatetags/eggs_extra.py import run_doctest
>
> run_doctest()
>
> but nothing happens.
>
> what can I do that that the doctests in the template filters are run
> with ./manage.py test?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---