Hi,

I'm experiencing the weirdest of errors with one of my tests. What
happens is the following: I create a queryset by on a model that has
(among other fields) an 'author' and a 'public' field. I want to limit
an anonymous user to only view those instances marked as
"public=True", so I do the usual:

objects = MyModel.objects.filter(public=True)

So far, so good. Then I try to slice that queryset depending on some
pre-validated pagination parameters like:

myslice = object[lower_bound:upper_bound]

Now, this is where things get weird. That code seems to work perfectly
well in the development server *and* when deployed to production
(Nginx + uWSGI). I decided to write a test to make sure that users not
providing credentials were only able to see exactly the same objects.
The way I test that (there might be a more elegant way) is by loading
the exact same dataset on the test method, and matching the results
with what my view returns (JSON-encoded version of the same data).
Problem is, when running the unit tests the queryset breaks. If I
check how many elements there are by using .count() it returns the
expected number, but when I try to slice it, it looks like it's empty
(in other words "assert False, queryset" will display "AssertionError:
[]".)

Luckily this just happens inside the test case, but it's kind of
annoying as it means I have a test that always fails. Any ideas what
might be happening?

Thanks in advance,
David

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

Reply via email to