Re: [Django] #14349: Add Belgium (be) localflavor

2010-09-28 Thread Django
#14349: Add Belgium (be) localflavor
-+--
  Reporter:  laurentluce | Owner:  laurentluce  
  
Status:  assigned| Milestone:  1.3  
  
 Component:  django.contrib.localflavor  |   Version:  SVN  
  
Resolution:  |  Keywords:  localflavor 
belgium
 Stage:  Accepted| Has_patch:  1
  
Needs_docs:  0   |   Needs_tests:  0
  
Needs_better_patch:  0   |  
-+--
Changes (by laurentluce):

  * has_patch:  0 => 1

Comment:

 patch contains the following:
 - forms.py with BEPostalCodeField, BEPhoneNumberField, BERegionSelect,
 BEProvinceSelect
 - be_regions.py with the 3 Belgium regions
 - be_provinces.py with the 11 Belgium provinces
 - added tests be.py and updated tests/regressiontests/forms/tests.py

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Changeset] r13959 - django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 20:29:10 -0500 (Tue, 28 Sep 2010)
New Revision: 13959

Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/tests.py
Log:
[1.2.X] Modified a fixtures_regress test case to make it more robust to 
database ordering.

Backport of r13958 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/tests.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/tests.py  
2010-09-29 01:20:34 UTC (rev 13958)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/tests.py  
2010-09-29 01:29:10 UTC (rev 13959)
@@ -304,11 +304,18 @@
 format='json',
 stdout=stdout
 )
-self.assertEqual(
-stdout.getvalue(),
-"""[{"pk": 1, "model": "fixtures_regress.animal", "fields": 
{"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}, 
{"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, 
"weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}, 
{"pk": 11, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 
2.2002, "name": "Platypus", "latin_name": "Ornithorhynchus 
anatinus"}}]"""
-)
 
+# Output order isn't guaranteed, so check for parts
+data = stdout.getvalue()
+lion_json = '{"pk": 1, "model": "fixtures_regress.animal", "fields": 
{"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}'
+emu_json = '{"pk": 10, "model": "fixtures_regress.animal", "fields": 
{"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius 
novaehollandiae"}}'
+platypus_json = '{"pk": 11, "model": "fixtures_regress.animal", 
"fields": {"count": 2, "weight": 2.2002, "name": "Platypus", 
"latin_name": "Ornithorhynchus anatinus"}}'
+
+self.assertEqual(len(data), len('[%s]' % ', '.join([lion_json, 
emu_json, platypus_json])))
+self.assertTrue(lion_json in data)
+self.assertTrue(emu_json in data)
+self.assertTrue(platypus_json in data)
+
 def test_proxy_model_included(self):
 """
 Regression for #11428 - Proxy models aren't included when you dumpdata

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



[Changeset] r13958 - django/trunk/tests/regressiontests/fixtures_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 20:20:34 -0500 (Tue, 28 Sep 2010)
New Revision: 13958

Modified:
   django/trunk/tests/regressiontests/fixtures_regress/tests.py
Log:
Modified a fixtures_regress test case to make it more robust to database 
ordering.

Modified: django/trunk/tests/regressiontests/fixtures_regress/tests.py
===
--- django/trunk/tests/regressiontests/fixtures_regress/tests.py
2010-09-28 15:09:06 UTC (rev 13957)
+++ django/trunk/tests/regressiontests/fixtures_regress/tests.py
2010-09-29 01:20:34 UTC (rev 13958)
@@ -304,11 +304,18 @@
 format='json',
 stdout=stdout
 )
-self.assertEqual(
-stdout.getvalue(),
-"""[{"pk": 1, "model": "fixtures_regress.animal", "fields": 
{"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}, 
{"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, 
"weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}, 
{"pk": 11, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 
2.2002, "name": "Platypus", "latin_name": "Ornithorhynchus 
anatinus"}}]"""
-)
 
+# Output order isn't guaranteed, so check for parts
+data = stdout.getvalue()
+lion_json = '{"pk": 1, "model": "fixtures_regress.animal", "fields": 
{"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}'
+emu_json = '{"pk": 10, "model": "fixtures_regress.animal", "fields": 
{"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius 
novaehollandiae"}}'
+platypus_json = '{"pk": 11, "model": "fixtures_regress.animal", 
"fields": {"count": 2, "weight": 2.2002, "name": "Platypus", 
"latin_name": "Ornithorhynchus anatinus"}}'
+
+self.assertEqual(len(data), len('[%s]' % ', '.join([lion_json, 
emu_json, platypus_json])))
+self.assertTrue(lion_json in data)
+self.assertTrue(emu_json in data)
+self.assertTrue(platypus_json in data)
+
 def test_proxy_model_included(self):
 """
 Regression for #11428 - Proxy models aren't included when you dumpdata

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



Re: [Django] #12420: "OneToOneField doesn't allow assignment of None"

2010-09-28 Thread Django
#12420: "OneToOneField doesn't allow assignment of None"
---+
  Reporter:  kbrownlees| Owner:  andrewsk
Status:  reopened  | Milestone:  1.2 
 Component:  Database layer (models, ORM)  |   Version:  SVN 
Resolution:|  Keywords:  
 Stage:  Ready for checkin | Has_patch:  1   
Needs_docs:  0 |   Needs_tests:  0   
Needs_better_patch:  0 |  
---+
Comment (by gsakkis):

 I don't think it's related, this dies fast and hard; I'm surprised it
 hasn't been noticed before. Using the models of #14043:

 {{{
 In [6]: bob = Person.objects.create(age=34)
 In [7]: bobs_soul = Soul.objects.create(person=bob)
 In [8]: bob.soul == bobs_soul
 Out[8]: True
 In [9]: bob.soul = None
 ---
 AttributeErrorTraceback (most recent call
 last)

 --> 258 setattr(value, self.related.field.attname,
 getattr(instance, self.related.field.rel.get_related_field().attname))
 259
 260 # Since we already know what the related object is, seed
 the related


 AttributeError: 'NoneType' object has no attribute 'person_id'
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #12420: "OneToOneField doesn't allow assignment of None"

2010-09-28 Thread Django
#12420: "OneToOneField doesn't allow assignment of None"
---+
  Reporter:  kbrownlees| Owner:  andrewsk
Status:  reopened  | Milestone:  1.2 
 Component:  Database layer (models, ORM)  |   Version:  SVN 
Resolution:|  Keywords:  
 Stage:  Ready for checkin | Has_patch:  1   
Needs_docs:  0 |   Needs_tests:  0   
Needs_better_patch:  0 |  
---+
Comment (by andrewsk):

 @gsakkis Is it related to #14043? Any test cases to trigger the error?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #3304: [patch] Support "httponly"-attribute in session cookie.

2010-09-28 Thread Django
#3304: [patch] Support "httponly"-attribute in session cookie.
-+--
  Reporter:  arvin   | Owner:  nobody  
Status:  new | Milestone:  
 Component:  Core framework  |   Version:  SVN 
Resolution:  |  Keywords:  session security
 Stage:  Accepted| Has_patch:  1   
Needs_docs:  0   |   Needs_tests:  1   
Needs_better_patch:  0   |  
-+--
Changes (by russellm):

  * component:  Contrib apps => Core framework
  * stage:  Someday/Maybe => Accepted

Comment:

 @jsocol: This can't get onto the 1.2.X branch, because that branch is in
 support mode, and this would represent a new feature. However, it can be
 considered for inclusion in trunk, which will become 1.3.

 The landscape seems to have changed a bit since Jacob "someday/maybe"d
 this three years ago; I'm happy to push this to accepted now, based on the
 existence of native Python support, and the
 [http://www.owasp.org/index.php/HttpOnly apparent level of browser
 support].

 As the ticket metadata indicates, the patch also requires tests. This is
 particularly important since we're introducing a workaround for Python 2.5
 and previous.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #10227: OneToOne fields with null=True raise DoesNotExist exception on related model

2010-09-28 Thread Django
#10227: OneToOne fields with null=True raise DoesNotExist exception on related
model
---+
  Reporter:  rvdrijst  | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.0

Resolution:|  Keywords:  onetoone 
related expection null
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Comment (by gsakkis):

 I ran into the same problem although in my case a hypothetical
 `related_null=True` would not help; a new default object would have be
 created. So instead of `related_null` I wrote a OneToOneField that uses
 `related_default`, a callable `lambda instance: value`. I posted the
 snippet at http://gist.github.com/601977.

 To me this seems more elegant, not only because it is a generalization of
 the `related_null` (just set `related_default=lambda instance: None`) but
 because `null` (and by association `related_null`) is a DB-level
 parameter, it determines whether a DB column is created as NULL or NOT
 NULL. In the case of a OneToOneField, the related model does not have a
 column linking to the model where the OneToOneField was defined (no
 `shop_id` column in the place table), so it doesn't make sense to say it's
 null.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #3304: [patch] Support "httponly"-attribute in session cookie.

2010-09-28 Thread Django
#3304: [patch] Support "httponly"-attribute in session cookie.
+---
  Reporter:  arvin  | Owner:  nobody  
Status:  new| Milestone:  
 Component:  Contrib apps   |   Version:  SVN 
Resolution: |  Keywords:  session security
 Stage:  Someday/Maybe  | Has_patch:  1   
Needs_docs:  0  |   Needs_tests:  1   
Needs_better_patch:  0  |  
+---
Changes (by jsocol):

 * cc: ja...@mozilla.com (added)

Comment:

 We (Mozilla) would love to see this patch get onto the 1.2.x branch.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14043: Incorrect and/or confusing behaviour with nullable OneToOneField

2010-09-28 Thread Django
#14043: Incorrect and/or confusing behaviour with nullable OneToOneField
---+
  Reporter:  theevilgeek   | Owner: 
  
Status:  new   | Milestone: 
  
 Component:  Database layer (models, ORM)  |   Version:  SVN
  
Resolution:|  Keywords:  
OneToOneField, cascading delete, nullable
 Stage:  Accepted  | Has_patch:  0  
  
Needs_docs:  0 |   Needs_tests:  0  
  
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * stage:  Unreviewed => Accepted

Comment:

 @gsakkis - You use the triage stage, not the action. Confusing, I know...
 :-)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #12420: "OneToOneField doesn't allow assignment of None"

2010-09-28 Thread Django
#12420: "OneToOneField doesn't allow assignment of None"
---+
  Reporter:  kbrownlees| Owner:  andrewsk
Status:  reopened  | Milestone:  1.2 
 Component:  Database layer (models, ORM)  |   Version:  SVN 
Resolution:|  Keywords:  
 Stage:  Ready for checkin | Has_patch:  1   
Needs_docs:  0 |   Needs_tests:  0   
Needs_better_patch:  0 |  
---+
Changes (by gsakkis):

 * cc: gsakkis (added)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #12420: "OneToOneField doesn't allow assignment of None"

2010-09-28 Thread Django
#12420: "OneToOneField doesn't allow assignment of None"
---+
  Reporter:  kbrownlees| Owner:  andrewsk
Status:  reopened  | Milestone:  1.2 
 Component:  Database layer (models, ORM)  |   Version:  SVN 
Resolution:|  Keywords:  
 Stage:  Ready for checkin | Has_patch:  1   
Needs_docs:  0 |   Needs_tests:  0   
Needs_better_patch:  0 |  
---+
Changes (by gsakkis):

  * status:  closed => reopened
  * resolution:  fixed =>

Comment:

 Lines 258 and 264 of
 
http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/related.py
 still fail if value is None.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Django] #14355: "readonly" fields don't display their "help_text" in admin

2010-09-28 Thread Django
#14355: "readonly" fields don't display their "help_text" in admin
--+-
 Reporter:  jester|   Owner:  nobody
   Status:  new   |   Milestone:
Component:  django.contrib.admin  | Version:  1.2   
 Keywords:  readonly help_text|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 == Steps to reproduce ==

 1. Define a Model, whose field(s) specify `help_text`, e.g.:

 {{{
 class MyModel(Model):
 my_regular_field = CharField(max_length=255, help_text="this is my
 regular field")
 my_readonly_field = CharField(max_length=255, help_text="this is my
 readonly field")
 }}}

 2. Define a ModelAdmin for your Model, including one of its fields in
 `readonly_fields`, e.g.:

 {{{
 class MyModelAdmin(ModelAdmin):
 fields = 'my_regular_field', 'my_readonly_field'
 readonly_fields = 'my_readonly_field',
 admin.site.register(MyModel, MyModelAdmin)
 }}}

 In the object view/edit screen, "My regular field" will have help text,
 "My readonly field" will not.

 == Expectation ==

 The expected behavior is that readonly fields will work just like
 "regular" fields, except their widget will be their plain value rather
 than a form element -- i.e., any string specified as "help_text" should be
 displayed after the field.

 == Uneducated guesswork ==

 I don't dig very deep into the workings of the admin very often, and so,
 obviously, what I'm about to say may be entirely unhelpful.  However, it
 appears that `helpers.AdminReadonlyField` constructs a limited, faux field
 object, a dict, at `self.field`, rather than assign the appropriate
 BoundField instance.  This is perhaps because readonly fields are not
 available to it in `self.form.fields`.  In the template,
 `field.field.field.help_text` fails, as the dict does not contain
 "help_text", (and I'm not sure where AdminReadonlyField would get it,
 anyway).

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14349: Add Belgium (be) localflavor

2010-09-28 Thread Django
#14349: Add Belgium (be) localflavor
-+--
  Reporter:  laurentluce | Owner:  laurentluce  
  
Status:  assigned| Milestone:  1.3  
  
 Component:  django.contrib.localflavor  |   Version:  SVN  
  
Resolution:  |  Keywords:  localflavor 
belgium
 Stage:  Accepted| Has_patch:  0
  
Needs_docs:  0   |   Needs_tests:  0
  
Needs_better_patch:  0   |  
-+--
Changes (by laurentluce):

  * stage:  Unreviewed => Accepted

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14353: unique_together new style is not working properly

2010-09-28 Thread Django
#14353: unique_together new style is not working properly
+---
  Reporter:  draxus | Owner:  nobody 
Status:  closed | Milestone: 
 Component:  Uncategorized  |   Version:  1.2
Resolution:  worksforme |  Keywords:  unique, restriction
 Stage:  Unreviewed | Has_patch:  0  
Needs_docs:  0  |   Needs_tests:  0  
Needs_better_patch:  0  |  
+---
Changes (by ramiro):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => worksforme
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 Tested this with Django 1.1, 1.2.X and trunk plus sqlite3 with the
 following model:

 {{{
 #!python
 from django.db import models

 class Foo(models.Model):
 driver = models.CharField(max_length=20)
 restaurant = models.CharField(max_length=30)
 age = models.PositiveIntegerField()

 class Meta:
 unique_together = (('driver', 'restaurant'),)
 #unique_together = ('driver', 'restaurant')
 }}}

 using both forms of `unique_together`. In all cases the SQL generated
 (`manage.py sqlall `) is:

 {{{
 #!sql
 BEGIN;CREATE TABLE "t14353_foo" (
 "id" integer NOT NULL PRIMARY KEY,
 "driver" varchar(20) NOT NULL,
 "restaurant" varchar(30) NOT NULL,
 "age" integer unsigned NOT NULL,
 UNIQUE ("driver", "restaurant")
 )
 ;COMMIT;
 }}}

 We'd need more details about you setup (exact Django version, revision and
 DB backend you are using) and a minimal example like the one above
 demonstrating the issue.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Django] #14354: Check password is not None in User.check_password

2010-09-28 Thread Django
#14354: Check password is not None in User.check_password
+---
 Reporter:  berryp  |   Owner:  nobody
   Status:  new |   Milestone:
Component:  Authentication  | Version:  1.2   
 Keywords:  |   Stage:  Unreviewed
Has_patch:  0   |  
+---
 I recently had an unexpected situation where users with no passwords would
 receive an error when trying to login. This is due to the fact that the
 User.check_password method does not check for missing passwords before
 calling get_hexdigest.

 It could be argued that all users should either have a password or an
 unusable password "!". However, as I am authenticating against a database
 that belongs to another system it is not an option to go and change all
 empty passwords to unusable ones. I would not expect authentication to
 raise an exception in this occasion.

 To get around this problem I simply inserted the following two lines at
 the top of the check_password function:

 {{{
 if self.password is None:
 return False
 }}}

 Additionally, would it not be a good idea to check that the password is
 not UNUSABLE_PASSWORD before trying to execute the code that checks the
 password? This would be a lot more elegant than executing code that is
 ultimately going to fail.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #7048: Support clearing FileFields with ModelForms

2010-09-28 Thread Django
#7048: Support clearing FileFields with ModelForms
---+
  Reporter:  jarrow| Owner:  carljm   
Status:  assigned  | Milestone:   
 Component:  Forms |   Version:  SVN  
Resolution:|  Keywords:  sprintSep2010
 Stage:  Accepted  | Has_patch:  1
Needs_docs:  0 |   Needs_tests:  0
Needs_better_patch:  0 |  
---+
Changes (by Althalus):

 * cc: mortas...@gmail.com (added)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14043: Incorrect and/or confusing behaviour with nullable OneToOneField

2010-09-28 Thread Django
#14043: Incorrect and/or confusing behaviour with nullable OneToOneField
---+
  Reporter:  theevilgeek   | Owner: 
  
Status:  new   | Milestone: 
  
 Component:  Database layer (models, ORM)  |   Version:  SVN
  
Resolution:|  Keywords:  
OneToOneField, cascading delete, nullable
 Stage:  Unreviewed| Has_patch:  0  
  
Needs_docs:  0 |   Needs_tests:  0  
  
Needs_better_patch:  0 |  
---+
Changes (by gsakkis):

  * owner:  gsakkis =>
  * status:  assigned => new

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14043: Incorrect and/or confusing behaviour with nullable OneToOneField

2010-09-28 Thread Django
#14043: Incorrect and/or confusing behaviour with nullable OneToOneField
---+
  Reporter:  theevilgeek   | Owner:  gsakkis
  
Status:  assigned  | Milestone: 
  
 Component:  Database layer (models, ORM)  |   Version:  SVN
  
Resolution:|  Keywords:  
OneToOneField, cascading delete, nullable
 Stage:  Unreviewed| Has_patch:  0  
  
Needs_docs:  0 |   Needs_tests:  0  
  
Needs_better_patch:  0 |  
---+
Changes (by gsakkis):

  * status:  new => assigned
 * cc: gsakkis (added)
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * owner:  nobody => gsakkis
  * needs_docs:  => 0

Comment:

 Confirmed here too, it's definitely non obvious, if not outright a bug.
 Also the SQL being issued on `bob.delete()` hints that something is fishy:
 {{{
 In [11]: bob.delete()
 UPDATE `lib_soul`
 SET `person_id` = NULL
 WHERE `id` IN (4)

 DELETE
 FROM `lib_soul`
 WHERE `id` IN (4)

 DELETE
 FROM `lib_person`
 WHERE `id` IN (2)
 }}}

 Why do an update if it is going to be deleted right after ?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Django] #14353: unique_together new style is not working properly

2010-09-28 Thread Django
#14353: unique_together new style is not working properly
-+--
 Reporter:  draxus   |   Owner:  nobody
   Status:  new  |   Milestone:
Component:  Uncategorized| Version:  1.2   
 Keywords:  unique, restriction  |   Stage:  Unreviewed
Has_patch:  0|  
-+--
 As you say in django docs:
 http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together

 unique_together = ("driver", "restaurant") <- this way doesn't create the
 unique restrictions in the DB

 unique_together = (("driver", "restaurant"),) <- this way works great

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Changeset] r13957 - django/branches/releases/1.2.X

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 10:09:06 -0500 (Tue, 28 Sep 2010)
New Revision: 13957

Modified:
   django/branches/releases/1.2.X/AUTHORS
Log:
[1.2.X] Corrected the spelling of David Brenneman's name in the AUTHORS file. 
Apologies, David.

Backport of r13956 from trunk.

Modified: django/branches/releases/1.2.X/AUTHORS
===
--- django/branches/releases/1.2.X/AUTHORS  2010-09-28 15:07:42 UTC (rev 
13956)
+++ django/branches/releases/1.2.X/AUTHORS  2010-09-28 15:09:06 UTC (rev 
13957)
@@ -82,7 +82,7 @@
 Matías Bordese
 Sean Brant
 Andrew Brehaut 
-David Brennenman 
+David Brenneman 
 brut.a...@gmail.com
 bthomas
 bt...@bestweb.net

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



[Changeset] r13956 - django/trunk

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 10:07:42 -0500 (Tue, 28 Sep 2010)
New Revision: 13956

Modified:
   django/trunk/AUTHORS
Log:
Corrected the spelling of David Brenneman's name in the AUTHORS file. 
Apologies, David.

Modified: django/trunk/AUTHORS
===
--- django/trunk/AUTHORS2010-09-28 14:53:21 UTC (rev 13955)
+++ django/trunk/AUTHORS2010-09-28 15:07:42 UTC (rev 13956)
@@ -82,7 +82,7 @@
 Matías Bordese
 Sean Brant
 Andrew Brehaut 
-David Brennenman 
+David Brenneman 
 brut.a...@gmail.com
 bthomas
 bt...@bestweb.net

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



[Changeset] r13955 - in django/branches/releases/1.2.X: . tests/regressiontests/fixtures_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 09:53:21 -0500 (Tue, 28 Sep 2010)
New Revision: 13955

Added:
   
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/tests.py
Modified:
   django/branches/releases/1.2.X/AUTHORS
   
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/models.py
Log:
[1.2.X] Migrated fixtures_regress doctests. Thanks to David Brenneman for the 
patch.

Backport of r13954 from trunk.

Modified: django/branches/releases/1.2.X/AUTHORS
===
--- django/branches/releases/1.2.X/AUTHORS  2010-09-28 14:52:20 UTC (rev 
13954)
+++ django/branches/releases/1.2.X/AUTHORS  2010-09-28 14:53:21 UTC (rev 
13955)
@@ -82,6 +82,7 @@
 Matías Bordese
 Sean Brant
 Andrew Brehaut 
+David Brennenman 
 brut.a...@gmail.com
 bthomas
 bt...@bestweb.net

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/models.py 
2010-09-28 14:52:20 UTC (rev 13954)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/fixtures_regress/models.py 
2010-09-28 14:53:21 UTC (rev 13955)
@@ -1,8 +1,8 @@
 from django.db import models, DEFAULT_DB_ALIAS
 from django.contrib.auth.models import User
 from django.conf import settings
-import os
 
+
 class Animal(models.Model):
 name = models.CharField(max_length=150)
 latin_name = models.CharField(max_length=150)
@@ -15,10 +15,6 @@
 def __unicode__(self):
 return self.name
 
-def animal_pre_save_check(signal, sender, instance, **kwargs):
-"A signal that is used to check the type of data loaded from fixtures"
-print 'Count = %s (%s)' % (instance.count, type(instance.count))
-print 'Weight = %s (%s)' % (instance.weight, type(instance.weight))
 
 class Plant(models.Model):
 name = models.CharField(max_length=150)
@@ -40,6 +36,7 @@
 name = None
 return unicode(name) + u' is owned by ' + unicode(self.owner)
 
+
 class Absolute(models.Model):
 name = models.CharField(max_length=40)
 
@@ -49,19 +46,23 @@
 super(Absolute, self).__init__(*args, **kwargs)
 Absolute.load_count += 1
 
+
 class Parent(models.Model):
 name = models.CharField(max_length=10)
 
 class Meta:
 ordering = ('id',)
 
+
 class Child(Parent):
 data = models.CharField(max_length=10)
 
+
 # Models to regression test #7572
 class Channel(models.Model):
 name = models.CharField(max_length=255)
 
+
 class Article(models.Model):
 title = models.CharField(max_length=255)
 channels = models.ManyToManyField(Channel)
@@ -69,6 +70,7 @@
 class Meta:
 ordering = ('id',)
 
+
 # Models to regression test #11428
 class Widget(models.Model):
 name = models.CharField(max_length=255)
@@ -79,16 +81,18 @@
 def __unicode__(self):
 return self.name
 
+
 class WidgetProxy(Widget):
 class Meta:
 proxy = True
 
-# Check for forward references in FKs and M2Ms with natural keys
 
+# Check for forward references in FKs and M2Ms with natural keys
 class TestManager(models.Manager):
 def get_by_natural_key(self, key):
 return self.get(name=key)
 
+
 class Store(models.Model):
 objects = TestManager()
 name = models.CharField(max_length=255)
@@ -102,6 +106,7 @@
 def natural_key(self):
 return (self.name,)
 
+
 class Person(models.Model):
 objects = TestManager()
 name = models.CharField(max_length=255)
@@ -118,6 +123,7 @@
 return (self.name,)
 natural_key.dependencies = ['fixtures_regress.store']
 
+
 class Book(models.Model):
 name = models.CharField(max_length=255)
 author = models.ForeignKey(Person)
@@ -133,10 +139,12 @@
 ', '.join(s.name for s in self.stores.all())
 )
 
+
 class NKManager(models.Manager):
 def get_by_natural_key(self, data):
 return self.get(data=data)
 
+
 class NKChild(Parent):
 data = models.CharField(max_length=10, unique=True)
 objects = NKManager()
@@ -147,6 +155,7 @@
 def __unicode__(self):
 return u'NKChild %s:%s' % (self.name, self.data)
 
+
 class RefToNKChild(models.Model):
 text = models.CharField(max_length=10)
 nk_fk = models.ForeignKey(NKChild, related_name='ref_fks')
@@ -159,260 +168,60 @@
 ', '.join(str(o) for o in self.nk_m2m.all())
 )
 
+
 # ome models with pathological circular dependencies
 class Circle1(models.Model):
 name = models.CharField(max_length=255)
+
 def natural_key(self):
 return self.name
 natural_key.dependencies = ['fixtures_regress.circle2']
 
+
 class Circle2(models.Model):
 name = models.CharField(max_length=255)
+
 def natural_key(self):
 return self.name
 natural_key.dependencies = ['fixtures_regress.circle1']

[Changeset] r13954 - in django/trunk: . tests/regressiontests/fixtures_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 09:52:20 -0500 (Tue, 28 Sep 2010)
New Revision: 13954

Added:
   django/trunk/tests/regressiontests/fixtures_regress/tests.py
Modified:
   django/trunk/AUTHORS
   django/trunk/tests/regressiontests/fixtures_regress/models.py
Log:
Migrated fixtures_regress doctests. Thanks to David Brenneman for the patch.

Modified: django/trunk/AUTHORS
===
--- django/trunk/AUTHORS2010-09-28 13:45:22 UTC (rev 13953)
+++ django/trunk/AUTHORS2010-09-28 14:52:20 UTC (rev 13954)
@@ -82,6 +82,7 @@
 Matías Bordese
 Sean Brant
 Andrew Brehaut 
+David Brennenman 
 brut.a...@gmail.com
 bthomas
 bt...@bestweb.net

Modified: django/trunk/tests/regressiontests/fixtures_regress/models.py
===
--- django/trunk/tests/regressiontests/fixtures_regress/models.py   
2010-09-28 13:45:22 UTC (rev 13953)
+++ django/trunk/tests/regressiontests/fixtures_regress/models.py   
2010-09-28 14:52:20 UTC (rev 13954)
@@ -1,8 +1,8 @@
 from django.db import models, DEFAULT_DB_ALIAS
 from django.contrib.auth.models import User
 from django.conf import settings
-import os
 
+
 class Animal(models.Model):
 name = models.CharField(max_length=150)
 latin_name = models.CharField(max_length=150)
@@ -15,10 +15,6 @@
 def __unicode__(self):
 return self.name
 
-def animal_pre_save_check(signal, sender, instance, **kwargs):
-"A signal that is used to check the type of data loaded from fixtures"
-print 'Count = %s (%s)' % (instance.count, type(instance.count))
-print 'Weight = %s (%s)' % (instance.weight, type(instance.weight))
 
 class Plant(models.Model):
 name = models.CharField(max_length=150)
@@ -40,6 +36,7 @@
 name = None
 return unicode(name) + u' is owned by ' + unicode(self.owner)
 
+
 class Absolute(models.Model):
 name = models.CharField(max_length=40)
 
@@ -49,19 +46,23 @@
 super(Absolute, self).__init__(*args, **kwargs)
 Absolute.load_count += 1
 
+
 class Parent(models.Model):
 name = models.CharField(max_length=10)
 
 class Meta:
 ordering = ('id',)
 
+
 class Child(Parent):
 data = models.CharField(max_length=10)
 
+
 # Models to regression test #7572
 class Channel(models.Model):
 name = models.CharField(max_length=255)
 
+
 class Article(models.Model):
 title = models.CharField(max_length=255)
 channels = models.ManyToManyField(Channel)
@@ -69,6 +70,7 @@
 class Meta:
 ordering = ('id',)
 
+
 # Models to regression test #11428
 class Widget(models.Model):
 name = models.CharField(max_length=255)
@@ -79,16 +81,18 @@
 def __unicode__(self):
 return self.name
 
+
 class WidgetProxy(Widget):
 class Meta:
 proxy = True
 
-# Check for forward references in FKs and M2Ms with natural keys
 
+# Check for forward references in FKs and M2Ms with natural keys
 class TestManager(models.Manager):
 def get_by_natural_key(self, key):
 return self.get(name=key)
 
+
 class Store(models.Model):
 objects = TestManager()
 name = models.CharField(max_length=255)
@@ -102,6 +106,7 @@
 def natural_key(self):
 return (self.name,)
 
+
 class Person(models.Model):
 objects = TestManager()
 name = models.CharField(max_length=255)
@@ -118,6 +123,7 @@
 return (self.name,)
 natural_key.dependencies = ['fixtures_regress.store']
 
+
 class Book(models.Model):
 name = models.CharField(max_length=255)
 author = models.ForeignKey(Person)
@@ -133,10 +139,12 @@
 ', '.join(s.name for s in self.stores.all())
 )
 
+
 class NKManager(models.Manager):
 def get_by_natural_key(self, data):
 return self.get(data=data)
 
+
 class NKChild(Parent):
 data = models.CharField(max_length=10, unique=True)
 objects = NKManager()
@@ -147,6 +155,7 @@
 def __unicode__(self):
 return u'NKChild %s:%s' % (self.name, self.data)
 
+
 class RefToNKChild(models.Model):
 text = models.CharField(max_length=10)
 nk_fk = models.ForeignKey(NKChild, related_name='ref_fks')
@@ -159,260 +168,60 @@
 ', '.join(str(o) for o in self.nk_m2m.all())
 )
 
+
 # ome models with pathological circular dependencies
 class Circle1(models.Model):
 name = models.CharField(max_length=255)
+
 def natural_key(self):
 return self.name
 natural_key.dependencies = ['fixtures_regress.circle2']
 
+
 class Circle2(models.Model):
 name = models.CharField(max_length=255)
+
 def natural_key(self):
 return self.name
 natural_key.dependencies = ['fixtures_regress.circle1']
 
+
 class Circle3(models.Model):
 name = models.CharField(max_length=255)
+
 def natural_key(self):
 return self.name
 natural_key.dependencies = ['fixtures_regress.circle3']
 
+
 

Re: [Django] #14352: MANIFEST.in refers to non-existant files

2010-09-28 Thread Django
#14352: MANIFEST.in refers to non-existant files
+---
  Reporter:  robhudson  | Owner:  nobody
Status:  closed | Milestone:
 Component:  Uncategorized  |   Version:  1.2   
Resolution:  fixed  |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by russellm):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => fixed
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 Fixed in r13760.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Django] #14352: MANIFEST.in refers to non-existant files

2010-09-28 Thread Django
#14352: MANIFEST.in refers to non-existant files
---+
 Reporter:  robhudson  |   Owner:  nobody
   Status:  new|   Milestone:
Component:  Uncategorized  | Version:  1.2   
 Keywords: |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 Installing Django shows two warnings, which are caused by non-existant
 files in the MANIFEST.in:

 {{{
 Installing collected packages: Django
   Running setup.py install for Django
 changing mode of build/scripts-2.6/django-admin.py from 644 to 755
 warning: no files found matching 'django/dispatch/LICENSE.txt'
 warning: no files found matching '*' under directory 'examples'
 }}}

 The attached patch fixes this.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Changeset] r13953 - django/branches/releases/1.2.X/tests/regressiontests/extra_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 08:45:22 -0500 (Tue, 28 Sep 2010)
New Revision: 13953

Added:
   django/branches/releases/1.2.X/tests/regressiontests/extra_regress/tests.py
Modified:
   django/branches/releases/1.2.X/tests/regressiontests/extra_regress/models.py
Log:
[1.2.X] Migrated extra_regress doctests. Thanks to Stephan Jaekel.

Backport of r13951 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/extra_regress/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/extra_regress/models.py
2010-09-28 13:44:49 UTC (rev 13952)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/extra_regress/models.py
2010-09-28 13:45:22 UTC (rev 13953)
@@ -4,10 +4,7 @@
 
 from django.contrib.auth.models import User
 from django.db import models
-from django.db.models.query import Q
-from django.utils.datastructures import SortedDict
 
-
 class RevisionableModel(models.Model):
 base = models.ForeignKey('self', null=True)
 title = models.CharField(blank=True, max_length=255)
@@ -41,177 +38,3 @@
 def __unicode__(self):
 return u'TestObject: %s,%s,%s' % (self.first,self.second,self.third)
 
-__test__ = {"API_TESTS": """
-# Regression tests for #7314 and #7372
-
->>> rm = RevisionableModel.objects.create(title='First Revision', 
when=datetime.datetime(2008, 9, 28, 10, 30, 0))
->>> rm.pk, rm.base.pk
-(1, 1)
-
->>> rm2 = rm.new_revision()
->>> rm2.title = "Second Revision"
->>> rm.when = datetime.datetime(2008, 9, 28, 14, 25, 0)
->>> rm2.save()
->>> print u"%s of %s" % (rm2.title, rm2.base.title)
-Second Revision of First Revision
-
->>> rm2.pk, rm2.base.pk
-(2, 1)
-
-Queryset to match most recent revision:
->>> qs = RevisionableModel.objects.extra(where=["%(table)s.id IN (SELECT 
MAX(rev.id) FROM %(table)s rev GROUP BY rev.base_id)" % {'table': 
RevisionableModel._meta.db_table,}],)
->>> qs
-[]
-
-Queryset to search for string in title:
->>> qs2 = RevisionableModel.objects.filter(title__contains="Revision")
->>> qs2
-[, ]
-
-Following queryset should return the most recent revision:
->>> qs & qs2
-[]
-
->>> u = User.objects.create_user(username="fred", password="secret", 
email="f...@example.com")
-
-# General regression tests: extra select parameters should stay tied to their
-# corresponding select portions. Applies when portions are updated or otherwise
-# moved around.
->>> qs = User.objects.extra(select=SortedDict((("alpha", "%s"), ("beta", "2"), 
("gamma", "%s"))), select_params=(1, 3))
->>> qs = qs.extra(select={"beta": 4})
->>> qs = qs.extra(select={"alpha": "%s"}, select_params=[5])
->>> result = {'alpha': 5, 'beta': 4, 'gamma': 3}
->>> list(qs.filter(id=u.id).values('alpha', 'beta', 'gamma')) == [result]
-True
-
-# Regression test for #7957: Combining extra() calls should leave the
-# corresponding parameters associated with the right extra() bit. I.e. internal
-# dictionary must remain sorted.
->>> User.objects.extra(select={"alpha": "%s"}, 
select_params=(1,)).extra(select={"beta": "%s"}, select_params=(2,))[0].alpha
-1
->>> User.objects.extra(select={"beta": "%s"}, 
select_params=(1,)).extra(select={"alpha": "%s"}, select_params=(2,))[0].alpha
-2
-
-# Regression test for #7961: When not using a portion of an extra(...) in a
-# query, remove any corresponding parameters from the query as well.
->>> list(User.objects.extra(select={"alpha": "%s"}, 
select_params=(-6,)).filter(id=u.id).values_list('id', flat=True)) == [u.id]
-True
-
-# Regression test for #8063: limiting a query shouldn't discard any extra()
-# bits.
->>> qs = User.objects.all().extra(where=['id=%s'], params=[u.id])
->>> qs
-[]
->>> qs[:1]
-[]
-
-# Regression test for #8039: Ordering sometimes removed relevant tables from
-# extra(). This test is the critical case: ordering uses a table, but then
-# removes the reference because of an optimisation. The table should still be
-# present because of the extra() call.
->>> Order.objects.extra(where=["username=%s"], params=["fred"], 
tables=["auth_user"]).order_by('created_by')
-[]
-
-# Regression test for #8819: Fields in the extra(select=...) list should be
-# available to extra(order_by=...).
->>> User.objects.filter(pk=u.id).extra(select={'extra_field': 1}).distinct()
-[]
->>> User.objects.filter(pk=u.id).extra(select={'extra_field': 1}, 
order_by=['extra_field'])
-[]
->>> User.objects.filter(pk=u.id).extra(select={'extra_field': 1}, 
order_by=['extra_field']).distinct()
-[]
-
-# When calling the dates() method on a queryset with extra selection columns,
-# we can (and should) ignore those columns. They don't change the result and
-# cause incorrect SQL to be produced otherwise.
->>> RevisionableModel.objects.extra(select={"the_answer": 'id'}).dates('when', 
'month')
-[datetime.datetime(2008, 9, 1, 0, 0)]
-
-# Regression test for #10256... If there is a values() clause, Extra columns 
are
-# only returned if they are explicitly mentioned.
->>> 

[Changeset] r13952 - django/branches/releases/1.2.X/tests/regressiontests/expressions_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 08:44:49 -0500 (Tue, 28 Sep 2010)
New Revision: 13952

Added:
   
django/branches/releases/1.2.X/tests/regressiontests/expressions_regress/tests.py
Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/expressions_regress/models.py
Log:
[1.2.X] Migrated expressions_regress doctests. Thanks to Stephan Jaekel.

Backport of r13950 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/expressions_regress/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/expressions_regress/models.py
  2010-09-28 13:42:09 UTC (rev 13951)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/expressions_regress/models.py
  2010-09-28 13:44:49 UTC (rev 13952)
@@ -1,13 +1,8 @@
 """
-Spanning tests for all the operations that F() expressions can perform.
+Model for testing arithmetic expressions.
 """
-from django.conf import settings
-from django.db import models, DEFAULT_DB_ALIAS
+from django.db import models
 
-#
-# Model for testing arithmetic expressions.
-#
-
 class Number(models.Model):
 integer = models.IntegerField(db_column='the_integer')
 float = models.FloatField(null=True, db_column='the_float')
@@ -15,123 +10,3 @@
 def __unicode__(self):
 return u'%i, %.3f' % (self.integer, self.float)
 
-
-__test__ = {'API_TESTS': """
->>> from django.db.models import F
-
->>> Number(integer=-1).save()
->>> Number(integer=42).save()
->>> Number(integer=1337).save()
-
-We can fill a value in all objects with an other value of the same object.
-
->>> Number.objects.update(float=F('integer'))
-3
->>> Number.objects.all()
-[, , ]
-
-We can increment a value of all objects in a query set.
-
->>> Number.objects.filter(integer__gt=0).update(integer=F('integer') + 1)
-2
->>> Number.objects.all()
-[, , ]
-
-We can filter for objects, where a value is not equals the value of an other 
field.
-
->>> Number.objects.exclude(float=F('integer'))
-[, ]
-
-Complex expressions of different connection types are possible.
-
->>> n = Number.objects.create(integer=10, float=123.45)
-
->>> Number.objects.filter(pk=n.pk).update(float=F('integer') + F('float') * 2)
-1
->>> Number.objects.get(pk=n.pk)
-
-
-# All supported operators work as expected.
-
->>> n = Number.objects.create(integer=42, float=15.5)
-
-# Left hand operators
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') + 15, 
float=F('float') + 42.7)
->>> Number.objects.get(pk=n.pk) # LH Addition of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') - 15, 
float=F('float') - 42.7)
->>> Number.objects.get(pk=n.pk) # LH Subtraction of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') * 15, 
float=F('float') * 42.7)
->>> Number.objects.get(pk=n.pk) # Multiplication of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') / 2, 
float=F('float') / 42.7)
->>> Number.objects.get(pk=n.pk) # LH Division of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') % 20)
->>> Number.objects.get(pk=n.pk) # LH Modulo arithmetic on integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') & 56)
->>> Number.objects.get(pk=n.pk) # LH Bitwise ands on integers
-
-
-# Right hand operators
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=15 + F('integer'), 
float=42.7 + F('float'))
->>> Number.objects.get(pk=n.pk) # RH Addition of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=15 - F('integer'), 
float=42.7 - F('float'))
->>> Number.objects.get(pk=n.pk) # RH Subtraction of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=15 * F('integer'), 
float=42.7 * F('float'))
->>> Number.objects.get(pk=n.pk) # RH Multiplication of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=640 / F('integer'), 
float=42.7 / F('float'))
->>> Number.objects.get(pk=n.pk) # RH Division of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=69 % F('integer'))
->>> 

[Changeset] r13951 - django/trunk/tests/regressiontests/extra_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 08:42:09 -0500 (Tue, 28 Sep 2010)
New Revision: 13951

Added:
   django/trunk/tests/regressiontests/extra_regress/tests.py
Modified:
   django/trunk/tests/regressiontests/extra_regress/models.py
Log:
Migrated extra_regress doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/extra_regress/models.py
===
--- django/trunk/tests/regressiontests/extra_regress/models.py  2010-09-28 
13:41:40 UTC (rev 13950)
+++ django/trunk/tests/regressiontests/extra_regress/models.py  2010-09-28 
13:42:09 UTC (rev 13951)
@@ -4,10 +4,7 @@
 
 from django.contrib.auth.models import User
 from django.db import models
-from django.db.models.query import Q
-from django.utils.datastructures import SortedDict
 
-
 class RevisionableModel(models.Model):
 base = models.ForeignKey('self', null=True)
 title = models.CharField(blank=True, max_length=255)
@@ -41,177 +38,3 @@
 def __unicode__(self):
 return u'TestObject: %s,%s,%s' % (self.first,self.second,self.third)
 
-__test__ = {"API_TESTS": """
-# Regression tests for #7314 and #7372
-
->>> rm = RevisionableModel.objects.create(title='First Revision', 
when=datetime.datetime(2008, 9, 28, 10, 30, 0))
->>> rm.pk, rm.base.pk
-(1, 1)
-
->>> rm2 = rm.new_revision()
->>> rm2.title = "Second Revision"
->>> rm.when = datetime.datetime(2008, 9, 28, 14, 25, 0)
->>> rm2.save()
->>> print u"%s of %s" % (rm2.title, rm2.base.title)
-Second Revision of First Revision
-
->>> rm2.pk, rm2.base.pk
-(2, 1)
-
-Queryset to match most recent revision:
->>> qs = RevisionableModel.objects.extra(where=["%(table)s.id IN (SELECT 
MAX(rev.id) FROM %(table)s rev GROUP BY rev.base_id)" % {'table': 
RevisionableModel._meta.db_table,}],)
->>> qs
-[]
-
-Queryset to search for string in title:
->>> qs2 = RevisionableModel.objects.filter(title__contains="Revision")
->>> qs2
-[, ]
-
-Following queryset should return the most recent revision:
->>> qs & qs2
-[]
-
->>> u = User.objects.create_user(username="fred", password="secret", 
email="f...@example.com")
-
-# General regression tests: extra select parameters should stay tied to their
-# corresponding select portions. Applies when portions are updated or otherwise
-# moved around.
->>> qs = User.objects.extra(select=SortedDict((("alpha", "%s"), ("beta", "2"), 
("gamma", "%s"))), select_params=(1, 3))
->>> qs = qs.extra(select={"beta": 4})
->>> qs = qs.extra(select={"alpha": "%s"}, select_params=[5])
->>> result = {'alpha': 5, 'beta': 4, 'gamma': 3}
->>> list(qs.filter(id=u.id).values('alpha', 'beta', 'gamma')) == [result]
-True
-
-# Regression test for #7957: Combining extra() calls should leave the
-# corresponding parameters associated with the right extra() bit. I.e. internal
-# dictionary must remain sorted.
->>> User.objects.extra(select={"alpha": "%s"}, 
select_params=(1,)).extra(select={"beta": "%s"}, select_params=(2,))[0].alpha
-1
->>> User.objects.extra(select={"beta": "%s"}, 
select_params=(1,)).extra(select={"alpha": "%s"}, select_params=(2,))[0].alpha
-2
-
-# Regression test for #7961: When not using a portion of an extra(...) in a
-# query, remove any corresponding parameters from the query as well.
->>> list(User.objects.extra(select={"alpha": "%s"}, 
select_params=(-6,)).filter(id=u.id).values_list('id', flat=True)) == [u.id]
-True
-
-# Regression test for #8063: limiting a query shouldn't discard any extra()
-# bits.
->>> qs = User.objects.all().extra(where=['id=%s'], params=[u.id])
->>> qs
-[]
->>> qs[:1]
-[]
-
-# Regression test for #8039: Ordering sometimes removed relevant tables from
-# extra(). This test is the critical case: ordering uses a table, but then
-# removes the reference because of an optimisation. The table should still be
-# present because of the extra() call.
->>> Order.objects.extra(where=["username=%s"], params=["fred"], 
tables=["auth_user"]).order_by('created_by')
-[]
-
-# Regression test for #8819: Fields in the extra(select=...) list should be
-# available to extra(order_by=...).
->>> User.objects.filter(pk=u.id).extra(select={'extra_field': 1}).distinct()
-[]
->>> User.objects.filter(pk=u.id).extra(select={'extra_field': 1}, 
order_by=['extra_field'])
-[]
->>> User.objects.filter(pk=u.id).extra(select={'extra_field': 1}, 
order_by=['extra_field']).distinct()
-[]
-
-# When calling the dates() method on a queryset with extra selection columns,
-# we can (and should) ignore those columns. They don't change the result and
-# cause incorrect SQL to be produced otherwise.
->>> RevisionableModel.objects.extra(select={"the_answer": 'id'}).dates('when', 
'month')
-[datetime.datetime(2008, 9, 1, 0, 0)]
-
-# Regression test for #10256... If there is a values() clause, Extra columns 
are
-# only returned if they are explicitly mentioned.
->>> TestObject(first='first', second='second', third='third').save()
-
->>> 

[Changeset] r13950 - django/trunk/tests/regressiontests/expressions_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 08:41:40 -0500 (Tue, 28 Sep 2010)
New Revision: 13950

Added:
   django/trunk/tests/regressiontests/expressions_regress/tests.py
Modified:
   django/trunk/tests/regressiontests/expressions_regress/models.py
Log:
Migrated expressions_regress doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/expressions_regress/models.py
===
--- django/trunk/tests/regressiontests/expressions_regress/models.py
2010-09-28 12:10:52 UTC (rev 13949)
+++ django/trunk/tests/regressiontests/expressions_regress/models.py
2010-09-28 13:41:40 UTC (rev 13950)
@@ -1,13 +1,8 @@
 """
-Spanning tests for all the operations that F() expressions can perform.
+Model for testing arithmetic expressions.
 """
-from django.conf import settings
-from django.db import models, DEFAULT_DB_ALIAS
+from django.db import models
 
-#
-# Model for testing arithmetic expressions.
-#
-
 class Number(models.Model):
 integer = models.IntegerField(db_column='the_integer')
 float = models.FloatField(null=True, db_column='the_float')
@@ -15,123 +10,3 @@
 def __unicode__(self):
 return u'%i, %.3f' % (self.integer, self.float)
 
-
-__test__ = {'API_TESTS': """
->>> from django.db.models import F
-
->>> Number(integer=-1).save()
->>> Number(integer=42).save()
->>> Number(integer=1337).save()
-
-We can fill a value in all objects with an other value of the same object.
-
->>> Number.objects.update(float=F('integer'))
-3
->>> Number.objects.all()
-[, , ]
-
-We can increment a value of all objects in a query set.
-
->>> Number.objects.filter(integer__gt=0).update(integer=F('integer') + 1)
-2
->>> Number.objects.all()
-[, , ]
-
-We can filter for objects, where a value is not equals the value of an other 
field.
-
->>> Number.objects.exclude(float=F('integer'))
-[, ]
-
-Complex expressions of different connection types are possible.
-
->>> n = Number.objects.create(integer=10, float=123.45)
-
->>> Number.objects.filter(pk=n.pk).update(float=F('integer') + F('float') * 2)
-1
->>> Number.objects.get(pk=n.pk)
-
-
-# All supported operators work as expected.
-
->>> n = Number.objects.create(integer=42, float=15.5)
-
-# Left hand operators
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') + 15, 
float=F('float') + 42.7)
->>> Number.objects.get(pk=n.pk) # LH Addition of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') - 15, 
float=F('float') - 42.7)
->>> Number.objects.get(pk=n.pk) # LH Subtraction of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') * 15, 
float=F('float') * 42.7)
->>> Number.objects.get(pk=n.pk) # Multiplication of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') / 2, 
float=F('float') / 42.7)
->>> Number.objects.get(pk=n.pk) # LH Division of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') % 20)
->>> Number.objects.get(pk=n.pk) # LH Modulo arithmetic on integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=F('integer') & 56)
->>> Number.objects.get(pk=n.pk) # LH Bitwise ands on integers
-
-
-# Right hand operators
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=15 + F('integer'), 
float=42.7 + F('float'))
->>> Number.objects.get(pk=n.pk) # RH Addition of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=15 - F('integer'), 
float=42.7 - F('float'))
->>> Number.objects.get(pk=n.pk) # RH Subtraction of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=15 * F('integer'), 
float=42.7 * F('float'))
->>> Number.objects.get(pk=n.pk) # RH Multiplication of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=640 / F('integer'), 
float=42.7 / F('float'))
->>> Number.objects.get(pk=n.pk) # RH Division of floats and integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = Number.objects.filter(pk=n.pk).update(integer=69 % F('integer'))
->>> Number.objects.get(pk=n.pk) # RH Modulo arithmetic on integers
-
-
->>> _ = Number.objects.filter(pk=n.pk).update(integer=42, float=15.5)
->>> _ = 

[Changeset] r13949 - django/branches/releases/1.2.X/tests/regressiontests/requests

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 07:10:52 -0500 (Tue, 28 Sep 2010)
New Revision: 13949

Modified:
   django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py
Log:
[1.2.X] Modified the requests unit tests so that they aren't dependent on 
dictionary ordering.

Backport of r13848 from trunk.

Modified: django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py  
2010-09-28 11:54:58 UTC (rev 13948)
+++ django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py  
2010-09-28 12:10:52 UTC (rev 13949)
@@ -10,22 +10,21 @@
 class RequestsTests(unittest.TestCase):
 
 def test_httprequest(self):
-self.assertEquals(repr(HttpRequest()),
-""
-)
+request = HttpRequest()
+self.assertEqual(request.GET.keys(), [])
+self.assertEqual(request.POST.keys(), [])
+self.assertEqual(request.COOKIES.keys(), [])
+self.assertEqual(request.META.keys(), [])
 
 def test_wsgirequest(self):
-self.assertEquals(repr(WSGIRequest({'PATH_INFO': 'bogus', 
'REQUEST_METHOD': 'bogus'})),
-""
-)
+request = WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 
'bogus'})
+self.assertEqual(request.GET.keys(), [])
+self.assertEqual(request.POST.keys(), [])
+self.assertEqual(request.COOKIES.keys(), [])
+self.assertEqual(set(request.META.keys()), set(['PATH_INFO', 
'REQUEST_METHOD', 'SCRIPT_NAME']))
+self.assertEqual(request.META['PATH_INFO'], 'bogus')
+self.assertEqual(request.META['REQUEST_METHOD'], 'bogus')
+self.assertEqual(request.META['SCRIPT_NAME'], '')
 
 def test_modpythonrequest(self):
 class FakeModPythonRequest(ModPythonRequest):
@@ -39,23 +38,22 @@
 
 req = Dummy()
 req.uri = 'bogus'
-self.assertEquals(repr(FakeModPythonRequest(req)),
-"")
+request = FakeModPythonRequest(req)
+self.assertEqual(request.path, 'bogus')
+self.assertEqual(request.GET.keys(), [])
+self.assertEqual(request.POST.keys(), [])
+self.assertEqual(request.COOKIES.keys(), [])
+self.assertEqual(request.META.keys(), [])
 
 def test_parse_cookie(self):
-self.assertEquals(parse_cookie('invalid:key=true'), {})
+self.assertEqual(parse_cookie('invalid:key=true'), {})
 
 def test_httprequest_location(self):
 request = HttpRequest()
-
self.assertEquals(request.build_absolute_uri(location="https://www.example.com/asdf;),
+
self.assertEqual(request.build_absolute_uri(location="https://www.example.com/asdf;),
 'https://www.example.com/asdf')
 
 request.get_host = lambda: 'www.example.com'
 request.path = ''
-
self.assertEquals(request.build_absolute_uri(location="/path/with:colons"),
+
self.assertEqual(request.build_absolute_uri(location="/path/with:colons"),
 'http://www.example.com/path/with:colons')

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



[Changeset] r13948 - django/trunk/tests/regressiontests/requests

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 06:54:58 -0500 (Tue, 28 Sep 2010)
New Revision: 13948

Modified:
   django/trunk/tests/regressiontests/requests/tests.py
Log:
Modified the requests unit tests so that they aren't dependent on dictionary 
ordering.

Modified: django/trunk/tests/regressiontests/requests/tests.py
===
--- django/trunk/tests/regressiontests/requests/tests.py2010-09-28 
08:36:09 UTC (rev 13947)
+++ django/trunk/tests/regressiontests/requests/tests.py2010-09-28 
11:54:58 UTC (rev 13948)
@@ -10,22 +10,21 @@
 class RequestsTests(unittest.TestCase):
 
 def test_httprequest(self):
-self.assertEquals(repr(HttpRequest()),
-""
-)
+request = HttpRequest()
+self.assertEqual(request.GET.keys(), [])
+self.assertEqual(request.POST.keys(), [])
+self.assertEqual(request.COOKIES.keys(), [])
+self.assertEqual(request.META.keys(), [])
 
 def test_wsgirequest(self):
-self.assertEquals(repr(WSGIRequest({'PATH_INFO': 'bogus', 
'REQUEST_METHOD': 'bogus'})),
-""
-)
+request = WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 
'bogus'})
+self.assertEqual(request.GET.keys(), [])
+self.assertEqual(request.POST.keys(), [])
+self.assertEqual(request.COOKIES.keys(), [])
+self.assertEqual(set(request.META.keys()), set(['PATH_INFO', 
'REQUEST_METHOD', 'SCRIPT_NAME']))
+self.assertEqual(request.META['PATH_INFO'], 'bogus')
+self.assertEqual(request.META['REQUEST_METHOD'], 'bogus')
+self.assertEqual(request.META['SCRIPT_NAME'], '')
 
 def test_modpythonrequest(self):
 class FakeModPythonRequest(ModPythonRequest):
@@ -39,25 +38,24 @@
 
 req = Dummy()
 req.uri = 'bogus'
-self.assertEquals(repr(FakeModPythonRequest(req)),
-"")
+request = FakeModPythonRequest(req)
+self.assertEqual(request.path, 'bogus')
+self.assertEqual(request.GET.keys(), [])
+self.assertEqual(request.POST.keys(), [])
+self.assertEqual(request.COOKIES.keys(), [])
+self.assertEqual(request.META.keys(), [])
 
 def test_parse_cookie(self):
-self.assertEquals(parse_cookie('invalid:key=true'), {})
+self.assertEqual(parse_cookie('invalid:key=true'), {})
 
 def test_httprequest_location(self):
 request = HttpRequest()
-
self.assertEquals(request.build_absolute_uri(location="https://www.example.com/asdf;),
+
self.assertEqual(request.build_absolute_uri(location="https://www.example.com/asdf;),
 'https://www.example.com/asdf')
 
 request.get_host = lambda: 'www.example.com'
 request.path = ''
-
self.assertEquals(request.build_absolute_uri(location="/path/with:colons"),
+
self.assertEqual(request.build_absolute_uri(location="/path/with:colons"),
 'http://www.example.com/path/with:colons')
 
 def test_near_expiration(self):
@@ -74,14 +72,14 @@
 time.sleep(0.001)
 response.set_cookie('datetime', expires=expires)
 datetime_cookie = response.cookies['datetime']
-self.assertEquals(datetime_cookie['max-age'], 10)
+self.assertEqual(datetime_cookie['max-age'], 10)
 
 def test_far_expiration(self):
 "Cookie will expire when an distant expiration time is provided"
 response = HttpResponse()
 response.set_cookie('datetime', expires=datetime(2028, 1, 1, 4, 5, 6))
 datetime_cookie = response.cookies['datetime']
-self.assertEquals(datetime_cookie['expires'], 'Sat, 01-Jan-2028 
04:05:06 GMT')
+self.assertEqual(datetime_cookie['expires'], 'Sat, 01-Jan-2028 
04:05:06 GMT')
 
 def test_max_age_expiration(self):
 "Cookie will expire if max_age is provided"

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



Re: [Django] #14329: Seeing test failure in regressiontests.request since 13809

2010-09-28 Thread Django
#14329: Seeing test failure in regressiontests.request since 13809
+---
  Reporter:  gabrielhurley  | Owner:  gabrielhurley
Status:  closed | Milestone:  1.3  
 Component:  HTTP handling  |   Version:  SVN  
Resolution:  duplicate  |  Keywords:   
 Stage:  Accepted   | Has_patch:  0
Needs_docs:  0  |   Needs_tests:  0
Needs_better_patch:  0  |  
+---
Changes (by lukeplant):

  * status:  assigned => closed
  * resolution:  => duplicate

Comment:

 Dupe of #14351

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Changeset] r13947 - django/trunk/tests/regressiontests

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:36:09 -0500 (Tue, 28 Sep 2010)
New Revision: 13947

Removed:
   django/trunk/tests/regressiontests/datastructures/
   django/trunk/tests/regressiontests/dateformat/
Log:
Clean up after git's inability to remove directories.

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



[Changeset] r13946 - in django/branches/releases/1.2.X/tests/regressiontests: . utils

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:31:01 -0500 (Tue, 28 Sep 2010)
New Revision: 13946

Removed:
   django/branches/releases/1.2.X/tests/regressiontests/dateformat/
Modified:
   django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
Log:
[1.2.X] Unified the regressiontests/dateformat tests with the 
regressiontests/utils/dateformat tests.

Backport of r13938 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
2010-09-28 08:30:22 UTC (rev 13945)
+++ django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
2010-09-28 08:31:01 UTC (rev 13946)
@@ -1,11 +1,36 @@
 from datetime import datetime, date
 import os
+import time
 import unittest
 
 from django.utils.dateformat import format
+from django.utils import dateformat, translation
 from django.utils.tzinfo import FixedOffset, LocalTimezone
 
 class DateFormatTests(unittest.TestCase):
+def setUp(self):
+self.old_TZ = os.environ.get('TZ')
+os.environ['TZ'] = 'Europe/Copenhagen'
+translation.activate('en-us')
+
+try:
+# Check if a timezone has been set
+time.tzset()
+self.tz_tests = True
+except AttributeError:
+# No timezone available. Don't run the tests that require a TZ
+self.tz_tests = False
+
+def tearDown(self):
+if self.old_TZ is None:
+del os.environ['TZ']
+else:
+os.environ['TZ'] = self.old_TZ
+
+# Cleanup - force re-evaluation of TZ environment variable.
+if self.tz_tests:
+time.tzset()
+
 def test_date(self):
 d = date(2009, 5, 16)
 self.assertEquals(date.fromtimestamp(int(format(d, 'U'))), d)
@@ -34,3 +59,71 @@
 utc = FixedOffset(0)
 udt = datetime(1970, 1, 1, tzinfo=utc)
 self.assertEquals(format(udt, 'U'), u'0')
+
+def test_empty_format(self):
+my_birthday = datetime(1979, 7, 8, 22, 00)
+
+self.assertEquals(dateformat.format(my_birthday, ''), u'')
+
+def test_am_pm(self):
+my_birthday = datetime(1979, 7, 8, 22, 00)
+
+self.assertEquals(dateformat.format(my_birthday, 'a'), u'p.m.')
+
+def test_date_formats(self):
+my_birthday = datetime(1979, 7, 8, 22, 00)
+timestamp = datetime(2008, 5, 19, 11, 45, 23, 123456)
+
+self.assertEquals(dateformat.format(my_birthday, 'A'), u'PM')
+self.assertEquals(dateformat.format(timestamp, 'c'), 
u'2008-05-19T11:45:23.123456')
+self.assertEquals(dateformat.format(my_birthday, 'd'), u'08')
+self.assertEquals(dateformat.format(my_birthday, 'j'), u'8')
+self.assertEquals(dateformat.format(my_birthday, 'l'), u'Sunday')
+self.assertEquals(dateformat.format(my_birthday, 'L'), u'False')
+self.assertEquals(dateformat.format(my_birthday, 'm'), u'07')
+self.assertEquals(dateformat.format(my_birthday, 'M'), u'Jul')
+self.assertEquals(dateformat.format(my_birthday, 'b'), u'jul')
+self.assertEquals(dateformat.format(my_birthday, 'n'), u'7')
+self.assertEquals(dateformat.format(my_birthday, 'N'), u'July')
+
+def test_time_formats(self):
+my_birthday = datetime(1979, 7, 8, 22, 00)
+
+self.assertEquals(dateformat.format(my_birthday, 'P'), u'10 p.m.')
+self.assertEquals(dateformat.format(my_birthday, 's'), u'00')
+self.assertEquals(dateformat.format(my_birthday, 'S'), u'th')
+self.assertEquals(dateformat.format(my_birthday, 't'), u'31')
+self.assertEquals(dateformat.format(my_birthday, 'w'), u'0')
+self.assertEquals(dateformat.format(my_birthday, 'W'), u'27')
+self.assertEquals(dateformat.format(my_birthday, 'y'), u'79')
+self.assertEquals(dateformat.format(my_birthday, 'Y'), u'1979')
+self.assertEquals(dateformat.format(my_birthday, 'z'), u'189')
+
+def test_dateformat(self):
+my_birthday = datetime(1979, 7, 8, 22, 00)
+
+self.assertEquals(dateformat.format(my_birthday, r'Y z \C\E\T'), 
u'1979 189 CET')
+
+self.assertEquals(dateformat.format(my_birthday, r'jS o\f F'), u'8th 
of July')
+
+def test_futuredates(self):
+the_future = datetime(2100, 10, 25, 0, 00)
+self.assertEquals(dateformat.format(the_future, r'Y'), u'2100')
+
+def test_timezones(self):
+my_birthday = datetime(1979, 7, 8, 22, 00)
+summertime = datetime(2005, 10, 30, 1, 00)
+wintertime = datetime(2005, 10, 30, 4, 00)
+timestamp = datetime(2008, 5, 19, 11, 45, 23, 123456)
+
+if self.tz_tests:
+self.assertEquals(dateformat.format(my_birthday, 'O'), u'+0100')
+self.assertEquals(dateformat.format(my_birthday, 'r'), u'Sun, 8 
Jul 1979 22:00:00 +0100')
+

[Changeset] r13945 - django/branches/releases/1.2.X/tests/regressiontests/defaultfilters

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:30:22 -0500 (Tue, 28 Sep 2010)
New Revision: 13945

Modified:
   django/branches/releases/1.2.X/tests/regressiontests/defaultfilters/tests.py
Log:
[1.2.X] Migrated defaultfilters doctests. Thanks to Stephan Jaekel

Backport of r13937 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/defaultfilters/tests.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/defaultfilters/tests.py
2010-09-28 08:29:58 UTC (rev 13944)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/defaultfilters/tests.py
2010-09-28 08:30:22 UTC (rev 13945)
@@ -1,596 +1,485 @@
 # -*- coding: utf-8 -*-
+import datetime
+import unittest
 
-r"""
->>> floatformat(7.7)
-u'7.7'
->>> floatformat(7.0)
-u'7'
->>> floatformat(0.7)
-u'0.7'
->>> floatformat(0.07)
-u'0.1'
->>> floatformat(0.007)
-u'0.0'
->>> floatformat(0.0)
-u'0'
->>> floatformat(7.7, 3)
-u'7.700'
->>> floatformat(6.00, 3)
-u'6.000'
->>> floatformat(6.20, 3)
-u'6.200'
->>> floatformat(6.20, -3)
-u'6.200'
->>> floatformat(13.1031, -3)
-u'13.103'
->>> floatformat(11.1197, -2)
-u'11.12'
->>> floatformat(11., -2)
-u'11'
->>> floatformat(11.01, -2)
-u'11.00'
->>> floatformat(8.2798, 3)
-u'8.280'
->>> floatformat(u'foo')
-u''
->>> floatformat(13.1031, u'bar')
-u'13.1031'
->>> floatformat(18.125, 2)
-u'18.13'
->>> floatformat(u'foo', u'bar')
-u''
->>> floatformat(u'¿Cómo esta usted?')
-u''
->>> floatformat(None)
-u''
->>> pos_inf = float(1e3)
->>> floatformat(pos_inf) == unicode(pos_inf)
-True
->>> neg_inf = float(-1e3)
->>> floatformat(neg_inf) == unicode(neg_inf)
-True
->>> nan = pos_inf / pos_inf
->>> floatformat(nan) == unicode(nan)
-True
+from django.template.defaultfilters import *
 
->>> class FloatWrapper(object):
-... def __init__(self, value):
-... self.value = value
-... def __float__(self):
-... return self.value
+class DefaultFiltersTests(unittest.TestCase):
 
->>> floatformat(FloatWrapper(11.01), -2)
-u'11.00'
+def test_floatformat(self):
+self.assertEqual(floatformat(7.7), u'7.7')
+self.assertEqual(floatformat(7.0), u'7')
+self.assertEqual(floatformat(0.7), u'0.7')
+self.assertEqual(floatformat(0.07), u'0.1')
+self.assertEqual(floatformat(0.007), u'0.0')
+self.assertEqual(floatformat(0.0), u'0')
+self.assertEqual(floatformat(7.7, 3), u'7.700')
+self.assertEqual(floatformat(6.00, 3), u'6.000')
+self.assertEqual(floatformat(6.20, 3), u'6.200')
+self.assertEqual(floatformat(6.20, -3), u'6.200')
+self.assertEqual(floatformat(13.1031, -3), u'13.103')
+self.assertEqual(floatformat(11.1197, -2), u'11.12')
+self.assertEqual(floatformat(11., -2), u'11')
+self.assertEqual(floatformat(11.01, -2), u'11.00')
+self.assertEqual(floatformat(8.2798, 3), u'8.280')
+self.assertEqual(floatformat(u'foo'), u'')
+self.assertEqual(floatformat(13.1031, u'bar'), u'13.1031')
+self.assertEqual(floatformat(18.125, 2), u'18.13')
+self.assertEqual(floatformat(u'foo', u'bar'), u'')
+self.assertEqual(floatformat(u'¿Cómo esta usted?'), u'')
+self.assertEqual(floatformat(None), u'')
 
->>> addslashes(u'"double quotes" and \'single quotes\'')
-u'\\"double quotes\\" and \\\'single quotes\\\''
+pos_inf = float(1e3)
+self.assertEqual(floatformat(pos_inf), unicode(pos_inf))
 
->>> addslashes(ur'\ : backslashes, too')
-u' : backslashes, too'
+neg_inf = float(-1e3)
+self.assertEqual(floatformat(neg_inf), unicode(neg_inf))
 
->>> capfirst(u'hello world')
-u'Hello world'
+nan = pos_inf / pos_inf
+self.assertEqual(floatformat(nan), unicode(nan))
 
->>> escapejs(u'"double quotes" and \'single quotes\'')
-u'\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027'
+class FloatWrapper(object):
+def __init__(self, value):
+self.value = value
+def __float__(self):
+return self.value
 
->>> escapejs(ur'\ : backslashes, too')
-u'\\u005C : backslashes, too'
+self.assertEqual(floatformat(FloatWrapper(11.01), -2), u'11.00')
 
->>> escapejs(u'and lots of whitespace: \r\n\t\v\f\b')
-u'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008'
+def test_addslashes(self):
+self.assertEqual(addslashes(u'"double quotes" and \'single quotes\''),
+  u'\\"double quotes\\" and \\\'single quotes\\\'')
 
->>> escapejs(ur'and this')
-u'\\u003Cscript\\u003Eand this\\u003C/script\\u003E'
+self.assertEqual(addslashes(ur'\ : backslashes, too'),
+  u' : backslashes, too')
 
->>> escapejs(u'paragraph separator:\u2029and line separator:\u2028')
-u'paragraph separator:\\u2029and line separator:\\u2028'
+def test_capfirst(self):

[Changeset] r13944 - in django/branches/releases/1.2.X/tests/regressiontests: . utils

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:29:58 -0500 (Tue, 28 Sep 2010)
New Revision: 13944

Removed:
   django/branches/releases/1.2.X/tests/regressiontests/datastructures/
Modified:
   django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
Log:
[1.2.X] Migrated regressiontest/datastructures doctest, and moved it into the 
existing utils datastructures package. Thanks to Stephan Jaekel.

Backport of r13937 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
2010-09-28 08:29:30 UTC (rev 13943)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
2010-09-28 08:29:58 UTC (rev 13944)
@@ -1,8 +1,23 @@
+"""
+Tests for stuff in django.utils.datastructures.
+"""
+import pickle
 import unittest
 
-from django.utils.datastructures import SortedDict
+from django.utils.datastructures import *
 
-class DatastructuresTests(unittest.TestCase):
+
+class DatastructuresTestCase(unittest.TestCase):
+def assertRaisesErrorWithMessage(self, error, message, callable,
+*args, **kwargs):
+self.assertRaises(error, callable, *args, **kwargs)
+try:
+callable(*args, **kwargs)
+except error, e:
+self.assertEqual(message, str(e))
+
+
+class SortedDictTests(DatastructuresTestCase):
 def setUp(self):
 self.d1 = SortedDict()
 self.d1[7] = 'seven'
@@ -66,3 +81,176 @@
 
 # Here the order of SortedDict values *is* what we are testing
 self.assertEquals(d.values(), ['second-two', 'one'])
+
+def test_overwrite(self):
+self.d1[1] = 'not one'
+self.assertEqual(self.d1[1], 'not one')
+self.assertEqual(self.d1.keys(), self.d1.copy().keys())
+
+def test_append(self):
+self.d1[13] = 'thirteen'
+self.assertEquals(
+repr(self.d1),
+"{7: 'seven', 1: 'one', 9: 'nine', 13: 'thirteen'}"
+)
+
+def test_pop(self):
+self.assertEquals(self.d1.pop(1, 'missing'), 'one')
+self.assertEquals(self.d1.pop(1, 'missing'), 'missing')
+
+# We don't know which item will be popped in popitem(), so we'll
+# just check that the number of keys has decreased.
+l = len(self.d1)
+self.d1.popitem()
+self.assertEquals(l - len(self.d1), 1)
+
+def test_dict_equality(self):
+d = SortedDict((i, i) for i in xrange(3))
+self.assertEquals(d, {0: 0, 1: 1, 2: 2})
+
+def test_tuple_init(self):
+d = SortedDict(((1, "one"), (0, "zero"), (2, "two")))
+self.assertEquals(repr(d), "{1: 'one', 0: 'zero', 2: 'two'}")
+
+def test_pickle(self):
+self.assertEquals(
+pickle.loads(pickle.dumps(self.d1, 2)),
+{7: 'seven', 1: 'one', 9: 'nine'}
+)
+
+def test_clear(self):
+self.d1.clear()
+self.assertEquals(self.d1, {})
+self.assertEquals(self.d1.keyOrder, [])
+
+class MergeDictTests(DatastructuresTestCase):
+
+def test_simple_mergedict(self):
+d1 = {'chris':'cool', 'camri':'cute', 'cotton':'adorable',
+  'tulip':'snuggable', 'twoofme':'firstone'}
+
+d2 = {'chris2':'cool2', 'camri2':'cute2', 'cotton2':'adorable2',
+  'tulip2':'snuggable2'}
+
+d3 = {'chris3':'cool3', 'camri3':'cute3', 'cotton3':'adorable3',
+  'tulip3':'snuggable3'}
+
+d4 = {'twoofme': 'secondone'}
+
+md = MergeDict(d1, d2, d3)
+
+self.assertEquals(md['chris'], 'cool')
+self.assertEquals(md['camri'], 'cute')
+self.assertEquals(md['twoofme'], 'firstone')
+
+md2 = md.copy()
+self.assertEquals(md2['chris'], 'cool')
+
+def test_mergedict_merges_multivaluedict(self):
+""" MergeDict can merge MultiValueDicts """
+
+multi1 = MultiValueDict({'key1': ['value1'],
+ 'key2': ['value2', 'value3']})
+
+multi2 = MultiValueDict({'key2': ['value4'],
+ 'key4': ['value5', 'value6']})
+
+mm = MergeDict(multi1, multi2)
+
+# Although 'key2' appears in both dictionaries,
+# only the first value is used.
+self.assertEquals(mm.getlist('key2'), ['value2', 'value3'])
+self.assertEquals(mm.getlist('key4'), ['value5', 'value6'])
+self.assertEquals(mm.getlist('undefined'), [])
+
+self.assertEquals(sorted(mm.keys()), ['key1', 'key2', 'key4'])
+self.assertEquals(len(mm.values()), 3)
+
+self.assertTrue('value1' in mm.values())
+
+self.assertEquals(sorted(mm.items(), key=lambda k: k[0]),
+  [('key1', 'value1'), ('key2', 'value3'),
+   ('key4', 'value6')])
+
+self.assertEquals([(k,mm.getlist(k)) for k in sorted(mm)],
+

[Changeset] r13943 - django/branches/releases/1.2.X/tests/regressiontests/utils

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:29:30 -0500 (Tue, 28 Sep 2010)
New Revision: 13943

Modified:
   django/branches/releases/1.2.X/tests/regressiontests/utils/checksums.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/datetime_safe.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/feedgenerator.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/functional.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/html.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/module_loading.py
   
django/branches/releases/1.2.X/tests/regressiontests/utils/simplelazyobject.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/termcolors.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/text.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/timesince.py
   django/branches/releases/1.2.X/tests/regressiontests/utils/tzinfo.py
Log:
[1.2.X] A few test optimizations; using native unittest where no 
Django-specific TestCase features are required.

Backport of r13935 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/checksums.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/utils/checksums.py 
2010-09-28 08:28:56 UTC (rev 13942)
+++ django/branches/releases/1.2.X/tests/regressiontests/utils/checksums.py 
2010-09-28 08:29:30 UTC (rev 13943)
@@ -1,8 +1,8 @@
-from django.test import TestCase
+import unittest
 
 from django.utils import checksums
 
-class TestUtilsChecksums(TestCase):
+class TestUtilsChecksums(unittest.TestCase):
 
 def check_output(self, function, value, output=None):
 """

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
2010-09-28 08:28:56 UTC (rev 13942)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/utils/datastructures.py
2010-09-28 08:29:30 UTC (rev 13943)
@@ -1,7 +1,8 @@
-from django.test import TestCase
+import unittest
+
 from django.utils.datastructures import SortedDict
 
-class DatastructuresTests(TestCase):
+class DatastructuresTests(unittest.TestCase):
 def setUp(self):
 self.d1 = SortedDict()
 self.d1[7] = 'seven'

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
2010-09-28 08:28:56 UTC (rev 13942)
+++ django/branches/releases/1.2.X/tests/regressiontests/utils/dateformat.py
2010-09-28 08:29:30 UTC (rev 13943)
@@ -1,10 +1,11 @@
+from datetime import datetime, date
 import os
-from unittest import TestCase
-from datetime import datetime, date
+import unittest
+
 from django.utils.dateformat import format
 from django.utils.tzinfo import FixedOffset, LocalTimezone
 
-class DateFormatTests(TestCase):
+class DateFormatTests(unittest.TestCase):
 def test_date(self):
 d = date(2009, 5, 16)
 self.assertEquals(date.fromtimestamp(int(format(d, 'U'))), d)

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/datetime_safe.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/utils/datetime_safe.py 
2010-09-28 08:28:56 UTC (rev 13942)
+++ django/branches/releases/1.2.X/tests/regressiontests/utils/datetime_safe.py 
2010-09-28 08:29:30 UTC (rev 13943)
@@ -1,9 +1,9 @@
-from django.test import TestCase
+import unittest
 
 from datetime import date as original_date, datetime as original_datetime
 from django.utils.datetime_safe import date, datetime
 
-class DatetimeTests(TestCase):
+class DatetimeTests(unittest.TestCase):
 
 def setUp(self):
 self.just_safe = (1900, 1, 1)

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/feedgenerator.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/utils/feedgenerator.py 
2010-09-28 08:28:56 UTC (rev 13942)
+++ django/branches/releases/1.2.X/tests/regressiontests/utils/feedgenerator.py 
2010-09-28 08:29:30 UTC (rev 13943)
@@ -1,9 +1,9 @@
 import datetime
-from unittest import TestCase
+import unittest
 
 from django.utils import feedgenerator, tzinfo
 
-class FeedgeneratorTest(TestCase):
+class FeedgeneratorTest(unittest.TestCase):
 """
 Tests for the low-level syndication feed framework.
 """

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/utils/functional.py

[Changeset] r13942 - django/branches/releases/1.2.X/tests/regressiontests/null_fk

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:28:56 -0500 (Tue, 28 Sep 2010)
New Revision: 13942

Added:
   django/branches/releases/1.2.X/tests/regressiontests/null_fk/tests.py
Modified:
   django/branches/releases/1.2.X/tests/regressiontests/null_fk/models.py
Log:
[1.2.X] Migrated null_fk doctests. Thanks to Stephan Jaekel.

Backport of r13934 from trunk.

Modified: django/branches/releases/1.2.X/tests/regressiontests/null_fk/models.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/null_fk/models.py  
2010-09-28 08:28:32 UTC (rev 13941)
+++ django/branches/releases/1.2.X/tests/regressiontests/null_fk/models.py  
2010-09-28 08:28:56 UTC (rev 13942)
@@ -31,37 +31,3 @@
 
 def __unicode__(self):
 return self.comment_text
-
-__test__ = {'API_TESTS':"""
-
->>> d = SystemDetails.objects.create(details='First details')
->>> s = SystemInfo.objects.create(system_name='First forum', system_details=d)
->>> f = Forum.objects.create(system_info=s, forum_name='First forum')
->>> p = Post.objects.create(forum=f, title='First Post')
->>> c1 = Comment.objects.create(post=p, comment_text='My first comment')
->>> c2 = Comment.objects.create(comment_text='My second comment')
-
-# Starting from comment, make sure that a .select_related(...) with a specified
-# set of fields will properly LEFT JOIN multiple levels of NULLs (and the 
things
-# that come after the NULLs, or else data that should exist won't). Regression
-# test for #7369.
->>> c = Comment.objects.select_related().get(id=1)
->>> c.post
-
->>> c = Comment.objects.select_related().get(id=2)
->>> print c.post
-None
-
->>> comments = Comment.objects.select_related('post__forum__system_info').all()
->>> [(c.id, c.comment_text, c.post) for c in comments]
-[(1, u'My first comment', ), (2, u'My second comment', None)]
-
-# Regression test for #7530, #7716.
->>> Comment.objects.select_related('post').filter(post__isnull=True)[0].post 
is None
-True
-
->>> comments = 
Comment.objects.select_related('post__forum__system_info__system_details')
->>> [(c.id, c.comment_text, c.post) for c in comments]
-[(1, u'My first comment', ), (2, u'My second comment', None)]
-
-"""}

Added: django/branches/releases/1.2.X/tests/regressiontests/null_fk/tests.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/null_fk/tests.py   
(rev 0)
+++ django/branches/releases/1.2.X/tests/regressiontests/null_fk/tests.py   
2010-09-28 08:28:56 UTC (rev 13942)
@@ -0,0 +1,42 @@
+from django.test import TestCase
+
+from regressiontests.null_fk.models import *
+
+class NullFkTests(TestCase):
+
+def test_null_fk(self):
+d = SystemDetails.objects.create(details='First details')
+s = SystemInfo.objects.create(system_name='First forum', 
system_details=d)
+f = Forum.objects.create(system_info=s, forum_name='First forum')
+p = Post.objects.create(forum=f, title='First Post')
+c1 = Comment.objects.create(post=p, comment_text='My first comment')
+c2 = Comment.objects.create(comment_text='My second comment')
+
+# Starting from comment, make sure that a .select_related(...) with a 
specified
+# set of fields will properly LEFT JOIN multiple levels of NULLs (and 
the things
+# that come after the NULLs, or else data that should exist won't). 
Regression
+# test for #7369.
+c = Comment.objects.select_related().get(id=1)
+self.assertEquals(c.post, p)
+self.assertEquals(Comment.objects.select_related().get(id=2).post, 
None)
+
+self.assertQuerysetEqual(
+Comment.objects.select_related('post__forum__system_info').all(),
+[
+(1, u'My first comment', ''),
+(2, u'My second comment', 'None')
+],
+transform = lambda c: (c.id, c.comment_text, repr(c.post))
+)
+
+# Regression test for #7530, #7716.
+
self.assertTrue(Comment.objects.select_related('post').filter(post__isnull=True)[0].post
 is None)
+
+self.assertQuerysetEqual(
+
Comment.objects.select_related('post__forum__system_info__system_details'),
+[
+(1, u'My first comment', ''),
+(2, u'My second comment', 'None')
+],
+transform = lambda c: (c.id, c.comment_text, repr(c.post))
+)

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



[Changeset] r13941 - django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:28:32 -0500 (Tue, 28 Sep 2010)
New Revision: 13941

Added:
   
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/tests.py
Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/models.py
Log:
[1.2.X] Migrated null_fk_ordering doctests. Thanks to Stephan Jaekel.

Backport of r13933 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/models.py 
2010-09-28 08:28:07 UTC (rev 13940)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/models.py 
2010-09-28 08:28:32 UTC (rev 13941)
@@ -47,40 +47,3 @@
 
 def __unicode__(self):
 return self.comment_text
-
-
-__test__ = {'API_TESTS': """
-# Regression test for #7512 -- ordering across nullable Foreign Keys shouldn't
-# exclude results
->>> author_1 = Author.objects.create(name='Tom Jones')
->>> author_2 = Author.objects.create(name='Bob Smith')
->>> article_1 = Article.objects.create(title='No author on this article')
->>> article_2 = Article.objects.create(author=author_1, title='This article 
written by Tom Jones')
->>> article_3 = Article.objects.create(author=author_2, title='This article 
written by Bob Smith')
-
-# We can't compare results directly (since different databases sort NULLs to
-# different ends of the ordering), but we can check that all results are
-# returned.
->>> len(list(Article.objects.all())) == 3
-True
-
->>> s = SystemInfo.objects.create(system_name='System Info')
->>> f = Forum.objects.create(system_info=s, forum_name='First forum')
->>> p = Post.objects.create(forum=f, title='First Post')
->>> c1 = Comment.objects.create(post=p, comment_text='My first comment')
->>> c2 = Comment.objects.create(comment_text='My second comment')
->>> s2 = SystemInfo.objects.create(system_name='More System Info')
->>> f2 = Forum.objects.create(system_info=s2, forum_name='Second forum')
->>> p2 = Post.objects.create(forum=f2, title='Second Post')
->>> c3 = Comment.objects.create(comment_text='Another first comment')
->>> c4 = Comment.objects.create(post=p2, comment_text='Another second comment')
-
-# We have to test this carefully. Some databases sort NULL values before
-# everything else, some sort them afterwards. So we extract the ordered list
-# and check the length. Before the fix, this list was too short (some values
-# were omitted).
->>> len(list(Comment.objects.all())) == 4
-True
-
-"""
-}

Added: 
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/tests.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/tests.py  
(rev 0)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/null_fk_ordering/tests.py  
2010-09-28 08:28:32 UTC (rev 13941)
@@ -0,0 +1,39 @@
+from django.test import TestCase
+
+from regressiontests.null_fk_ordering.models import *
+
+class NullFkOrderingTests(TestCase):
+
+def test_ordering_across_null_fk(self):
+"""
+Regression test for #7512
+
+ordering across nullable Foreign Keys shouldn't exclude results
+"""
+author_1 = Author.objects.create(name='Tom Jones')
+author_2 = Author.objects.create(name='Bob Smith')
+article_1 = Article.objects.create(title='No author on this article')
+article_2 = Article.objects.create(author=author_1, title='This 
article written by Tom Jones')
+article_3 = Article.objects.create(author=author_2, title='This 
article written by Bob Smith')
+
+# We can't compare results directly (since different databases sort 
NULLs to
+# different ends of the ordering), but we can check that all results 
are
+# returned.
+self.assertTrue(len(list(Article.objects.all())) == 3)
+
+s = SystemInfo.objects.create(system_name='System Info')
+f = Forum.objects.create(system_info=s, forum_name='First forum')
+p = Post.objects.create(forum=f, title='First Post')
+c1 = Comment.objects.create(post=p, comment_text='My first comment')
+c2 = Comment.objects.create(comment_text='My second comment')
+s2 = SystemInfo.objects.create(system_name='More System Info')
+f2 = Forum.objects.create(system_info=s2, forum_name='Second forum')
+p2 = Post.objects.create(forum=f2, title='Second Post')
+c3 = Comment.objects.create(comment_text='Another first comment')
+c4 = Comment.objects.create(post=p2, comment_text='Another second 
comment')
+
+# We have to test this carefully. Some databases sort NULL values 
before
+# everything else, some sort them afterwards. So we extract the 
ordered list
+# and check the length. Before the fix, this list was too short (some 

[Changeset] r13940 - django/branches/releases/1.2.X/tests/regressiontests/null_queries

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:28:07 -0500 (Tue, 28 Sep 2010)
New Revision: 13940

Added:
   django/branches/releases/1.2.X/tests/regressiontests/null_queries/tests.py
Modified:
   django/branches/releases/1.2.X/tests/regressiontests/null_queries/models.py
Log:
[1.2.X] Migrated null_queries doctests. Thanks to Stephan Jaekel.

Backport of r13932 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/null_queries/models.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/null_queries/models.py 
2010-09-28 08:27:43 UTC (rev 13939)
+++ django/branches/releases/1.2.X/tests/regressiontests/null_queries/models.py 
2010-09-28 08:28:07 UTC (rev 13940)
@@ -23,60 +23,3 @@
 class Inner(models.Model):
 first = models.ForeignKey(OuterA)
 second = models.ForeignKey(OuterB, null=True)
-
-__test__ = {'API_TESTS':"""
-# Regression test for the use of None as a query value. None is interpreted as
-# an SQL NULL, but only in __exact queries.
-# Set up some initial polls and choices
->>> p1 = Poll(question='Why?')
->>> p1.save()
->>> c1 = Choice(poll=p1, choice='Because.')
->>> c1.save()
->>> c2 = Choice(poll=p1, choice='Why Not?')
->>> c2.save()
-
-# Exact query with value None returns nothing ("is NULL" in sql, but every 'id'
-# field has a value).
->>> Choice.objects.filter(choice__exact=None)
-[]
-
-Excluding the previous result returns everything.
->>> Choice.objects.exclude(choice=None).order_by('id')
-[, ]
-
-# Valid query, but fails because foo isn't a keyword
->>> Choice.objects.filter(foo__exact=None)
-Traceback (most recent call last):
-...
-FieldError: Cannot resolve keyword 'foo' into field. Choices are: choice, id, 
poll
-
-# Can't use None on anything other than __exact
->>> Choice.objects.filter(id__gt=None)
-Traceback (most recent call last):
-...
-ValueError: Cannot use None as a query value
-
-# Can't use None on anything other than __exact
->>> Choice.objects.filter(foo__gt=None)
-Traceback (most recent call last):
-...
-ValueError: Cannot use None as a query value
-
-# Related managers use __exact=None implicitly if the object hasn't been saved.
->>> p2 = Poll(question="How?")
->>> p2.choice_set.all()
-[]
-
-# Querying across reverse relations and then another relation should insert
-# outer joins correctly so as not to exclude results.
->>> obj = OuterA.objects.create()
->>> OuterA.objects.filter(inner__second=None)
-[]
->>> OuterA.objects.filter(inner__second__data=None)
-[]
->>> _ = Inner.objects.create(first=obj)
->>> Inner.objects.filter(first__inner__second=None)
-[]
-
-
-"""}

Added: 
django/branches/releases/1.2.X/tests/regressiontests/null_queries/tests.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/null_queries/tests.py  
(rev 0)
+++ django/branches/releases/1.2.X/tests/regressiontests/null_queries/tests.py  
2010-09-28 08:28:07 UTC (rev 13940)
@@ -0,0 +1,69 @@
+from django.test import TestCase
+from django.core.exceptions import FieldError
+
+from regressiontests.null_queries.models import *
+
+
+class NullQueriesTests(TestCase):
+
+def test_none_as_null(self):
+"""
+Regression test for the use of None as a query value.
+
+None is interpreted as an SQL NULL, but only in __exact queries.
+Set up some initial polls and choices
+"""
+p1 = Poll(question='Why?')
+p1.save()
+c1 = Choice(poll=p1, choice='Because.')
+c1.save()
+c2 = Choice(poll=p1, choice='Why Not?')
+c2.save()
+
+# Exact query with value None returns nothing ("is NULL" in sql,
+# but every 'id' field has a value).
+self.assertQuerysetEqual(Choice.objects.filter(choice__exact=None), [])
+
+# Excluding the previous result returns everything.
+self.assertQuerysetEqual(
+Choice.objects.exclude(choice=None).order_by('id'),
+[
+'',
+''
+]
+)
+
+# Valid query, but fails because foo isn't a keyword
+self.assertRaises(FieldError, Choice.objects.filter, foo__exact=None)
+
+# Can't use None on anything other than __exact
+self.assertRaises(ValueError, Choice.objects.filter, id__gt=None)
+
+# Can't use None on anything other than __exact
+self.assertRaises(ValueError, Choice.objects.filter, foo__gt=None)
+
+# Related managers use __exact=None implicitly if the object hasn't 
been saved.
+p2 = Poll(question="How?")
+self.assertEquals(repr(p2.choice_set.all()), '[]')
+
+def test_reverse_relations(self):
+"""
+Querying across reverse relations and then another relation should
+insert outer joins correctly so as not to exclude results.
+"""
+obj = OuterA.objects.create()
+

[Changeset] r13939 - django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:27:43 -0500 (Tue, 28 Sep 2010)
New Revision: 13939

Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/models.py
   
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/tests.py
Log:
[1.2.X] Migrated one_to_one_regress doctests. Thanks to Stephan Jaekel.

Backport of r13931 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/models.py
   2010-09-28 08:19:42 UTC (rev 13938)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/models.py
   2010-09-28 08:27:43 UTC (rev 13939)
@@ -41,104 +41,3 @@
 
 class Pointer2(models.Model):
 other = models.OneToOneField(Target)
-
-__test__ = {'API_TESTS':"""
-# Regression test for #1064 and #1506: Check that we create models via the m2m
-# relation if the remote model has a OneToOneField.
->>> p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
->>> p1.save()
->>> r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False)
->>> r.save()
->>> f = Favorites(name = 'Fred')
->>> f.save()
->>> f.restaurants = [r]
->>> f.restaurants.all()
-[]
-
-# Regression test for #7173: Check that the name of the cache for the
-# reverse object is correct.
->>> b = Bar(place=p1, serves_cocktails=False)
->>> b.save()
->>> p1.restaurant
-
->>> p1.bar
-
-
-#
-# Regression test for #6886 (the related-object cache)
-#
-
-# Look up the objects again so that we get "fresh" objects
->>> p = Place.objects.get(name="Demon Dogs")
->>> r = p.restaurant
-
-# Accessing the related object again returns the exactly same object
->>> p.restaurant is r
-True
-
-# But if we kill the cache, we get a new object
->>> del p._restaurant_cache
->>> p.restaurant is r
-False
-
-# Reassigning the Restaurant object results in an immediate cache update
-# We can't use a new Restaurant because that'll violate one-to-one, but
-# with a new *instance* the is test below will fail if #6886 regresses.
->>> r2 = Restaurant.objects.get(pk=r.pk)
->>> p.restaurant = r2
->>> p.restaurant is r2
-True
-
-# Assigning None succeeds if field is null=True.
->>> ug_bar = UndergroundBar.objects.create(place=p, serves_cocktails=False)
->>> ug_bar.place = None
->>> ug_bar.place is None
-True
-
-# Assigning None fails: Place.restaurant is null=False
->>> p.restaurant = None
-Traceback (most recent call last):
-...
-ValueError: Cannot assign None: "Place.restaurant" does not allow null values.
-
-# You also can't assign an object of the wrong type here
->>> p.restaurant = p
-Traceback (most recent call last):
-...
-ValueError: Cannot assign "": "Place.restaurant" 
must be a "Restaurant" instance.
-
-# Creation using keyword argument should cache the related object.
->>> p = Place.objects.get(name="Demon Dogs")
->>> r = Restaurant(place=p)
->>> r.place is p
-True
-
-# Creation using keyword argument and unsaved related instance (#8070).
->>> p = Place()
->>> r = Restaurant(place=p)
->>> r.place is p
-True
-
-# Creation using attname keyword argument and an id will cause the related
-# object to be fetched.
->>> p = Place.objects.get(name="Demon Dogs")
->>> r = Restaurant(place_id=p.id)
->>> r.place is p
-False
->>> r.place == p
-True
-
-# Regression test for #9968: filtering reverse one-to-one relations with
-# primary_key=True was misbehaving. We test both (primary_key=True & False)
-# cases here to prevent any reappearance of the problem.
->>> _ = Target.objects.create()
->>> Target.objects.filter(pointer=None)
-[]
->>> Target.objects.exclude(pointer=None)
-[]
->>> Target.objects.filter(pointer2=None)
-[]
->>> Target.objects.exclude(pointer2=None)
-[]
-
-"""}

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/tests.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/tests.py
2010-09-28 08:19:42 UTC (rev 13938)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/one_to_one_regress/tests.py
2010-09-28 08:27:43 UTC (rev 13939)
@@ -1,22 +1,130 @@
 from django.test import TestCase
-from regressiontests.one_to_one_regress.models import Place, UndergroundBar
+from regressiontests.one_to_one_regress.models import *
 
-class OneToOneDeletionTests(TestCase):
+class OneToOneRegressionTests(TestCase):
+
+def setUp(self):
+self.p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
+self.p1.save()
+self.r1 = Restaurant(place=self.p1, serves_hot_dogs=True, 
serves_pizza=False)
+self.r1.save()
+self.b1 = Bar(place=self.p1, serves_cocktails=False)
+self.b1.save()
+
 def test_reverse_relationship_cache_cascade(self):
 """
 Regression test for #9023: accessing the reverse relationship shouldn't
 result 

[Changeset] r13938 - in django/trunk/tests/regressiontests: dateformat utils

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:19:42 -0500 (Tue, 28 Sep 2010)
New Revision: 13938

Removed:
   django/trunk/tests/regressiontests/dateformat/__init__.py
   django/trunk/tests/regressiontests/dateformat/models.py
   django/trunk/tests/regressiontests/dateformat/tests.py
Modified:
   django/trunk/tests/regressiontests/utils/dateformat.py
Log:
Unified the regressiontests/dateformat tests with the 
regressiontests/utils/dateformat tests.

Deleted: django/trunk/tests/regressiontests/dateformat/__init__.py
===

Deleted: django/trunk/tests/regressiontests/dateformat/models.py
===

Deleted: django/trunk/tests/regressiontests/dateformat/tests.py
===
--- django/trunk/tests/regressiontests/dateformat/tests.py  2010-09-28 
08:19:04 UTC (rev 13937)
+++ django/trunk/tests/regressiontests/dateformat/tests.py  2010-09-28 
08:19:42 UTC (rev 13938)
@@ -1,96 +0,0 @@
-
-from django.utils import dateformat, translation
-from unittest import TestCase
-import datetime, os, time
-
-class DateFormatTests(TestCase):
-def setUp(self):
-self.old_TZ = os.environ.get('TZ')
-os.environ['TZ'] = 'Europe/Copenhagen'
-translation.activate('en-us')
-
-try:
-# Check if a timezone has been set
-time.tzset()
-self.tz_tests = True
-except AttributeError:
-# No timezone available. Don't run the tests that require a TZ
-self.tz_tests = False
-
-def tearDown(self):
-if self.old_TZ is None:
-del os.environ['TZ']
-else:
-os.environ['TZ'] = self.old_TZ
-
-# Cleanup - force re-evaluation of TZ environment variable.
-if self.tz_tests:
-time.tzset()
-
-def test_empty_format(self):
-my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
-
-self.assertEquals(dateformat.format(my_birthday, ''), u'')
-
-def test_am_pm(self):
-my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
-
-self.assertEquals(dateformat.format(my_birthday, 'a'), u'p.m.')
-
-def test_date_formats(self):
-my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
-timestamp = datetime.datetime(2008, 5, 19, 11, 45, 23, 123456)
-
-self.assertEquals(dateformat.format(my_birthday, 'A'), u'PM')
-self.assertEquals(dateformat.format(timestamp, 'c'), 
u'2008-05-19T11:45:23.123456')
-self.assertEquals(dateformat.format(my_birthday, 'd'), u'08')
-self.assertEquals(dateformat.format(my_birthday, 'j'), u'8')
-self.assertEquals(dateformat.format(my_birthday, 'l'), u'Sunday')
-self.assertEquals(dateformat.format(my_birthday, 'L'), u'False')
-self.assertEquals(dateformat.format(my_birthday, 'm'), u'07')
-self.assertEquals(dateformat.format(my_birthday, 'M'), u'Jul')
-self.assertEquals(dateformat.format(my_birthday, 'b'), u'jul')
-self.assertEquals(dateformat.format(my_birthday, 'n'), u'7')
-self.assertEquals(dateformat.format(my_birthday, 'N'), u'July')
-
-def test_time_formats(self):
-my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
-
-self.assertEquals(dateformat.format(my_birthday, 'P'), u'10 p.m.')
-self.assertEquals(dateformat.format(my_birthday, 's'), u'00')
-self.assertEquals(dateformat.format(my_birthday, 'S'), u'th')
-self.assertEquals(dateformat.format(my_birthday, 't'), u'31')
-self.assertEquals(dateformat.format(my_birthday, 'w'), u'0')
-self.assertEquals(dateformat.format(my_birthday, 'W'), u'27')
-self.assertEquals(dateformat.format(my_birthday, 'y'), u'79')
-self.assertEquals(dateformat.format(my_birthday, 'Y'), u'1979')
-self.assertEquals(dateformat.format(my_birthday, 'z'), u'189')
-
-def test_dateformat(self):
-my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
-
-self.assertEquals(dateformat.format(my_birthday, r'Y z \C\E\T'), 
u'1979 189 CET')
-
-self.assertEquals(dateformat.format(my_birthday, r'jS o\f F'), u'8th 
of July')
-
-def test_futuredates(self):
-the_future = datetime.datetime(2100, 10, 25, 0, 00)
-self.assertEquals(dateformat.format(the_future, r'Y'), u'2100')
-
-def test_timezones(self):
-my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
-summertime = datetime.datetime(2005, 10, 30, 1, 00)
-wintertime = datetime.datetime(2005, 10, 30, 4, 00)
-timestamp = datetime.datetime(2008, 5, 19, 11, 45, 23, 123456)
-
-if self.tz_tests:
-self.assertEquals(dateformat.format(my_birthday, 'O'), u'+0100')
-self.assertEquals(dateformat.format(my_birthday, 'r'), u'Sun, 8 
Jul 1979 22:00:00 +0100')
-self.assertEquals(dateformat.format(my_birthday, 'T'), u'CET')
-

[Changeset] r13937 - django/trunk/tests/regressiontests/defaultfilters

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:19:04 -0500 (Tue, 28 Sep 2010)
New Revision: 13937

Modified:
   django/trunk/tests/regressiontests/defaultfilters/tests.py
Log:
Migrated defaultfilters doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/defaultfilters/tests.py
===
--- django/trunk/tests/regressiontests/defaultfilters/tests.py  2010-09-28 
08:18:39 UTC (rev 13936)
+++ django/trunk/tests/regressiontests/defaultfilters/tests.py  2010-09-28 
08:19:04 UTC (rev 13937)
@@ -1,605 +1,489 @@
 # -*- coding: utf-8 -*-
+import datetime
+import unittest
 
-r"""
->>> floatformat(7.7)
-u'7.7'
->>> floatformat(7.0)
-u'7'
->>> floatformat(0.7)
-u'0.7'
->>> floatformat(0.07)
-u'0.1'
->>> floatformat(0.007)
-u'0.0'
->>> floatformat(0.0)
-u'0'
->>> floatformat(7.7, 3)
-u'7.700'
->>> floatformat(6.00, 3)
-u'6.000'
->>> floatformat(6.20, 3)
-u'6.200'
->>> floatformat(6.20, -3)
-u'6.200'
->>> floatformat(13.1031, -3)
-u'13.103'
->>> floatformat(11.1197, -2)
-u'11.12'
->>> floatformat(11., -2)
-u'11'
->>> floatformat(11.01, -2)
-u'11.00'
->>> floatformat(8.2798, 3)
-u'8.280'
->>> floatformat(u'foo')
-u''
->>> floatformat(13.1031, u'bar')
-u'13.1031'
->>> floatformat(18.125, 2)
-u'18.13'
->>> floatformat(u'foo', u'bar')
-u''
->>> floatformat(u'¿Cómo esta usted?')
-u''
->>> floatformat(None)
-u''
->>> pos_inf = float(1e3)
->>> floatformat(pos_inf) == unicode(pos_inf)
-True
->>> neg_inf = float(-1e3)
->>> floatformat(neg_inf) == unicode(neg_inf)
-True
->>> nan = pos_inf / pos_inf
->>> floatformat(nan) == unicode(nan)
-True
+from django.template.defaultfilters import *
 
->>> class FloatWrapper(object):
-... def __init__(self, value):
-... self.value = value
-... def __float__(self):
-... return self.value
+class DefaultFiltersTests(unittest.TestCase):
 
->>> floatformat(FloatWrapper(11.01), -2)
-u'11.00'
+def test_floatformat(self):
+self.assertEqual(floatformat(7.7), u'7.7')
+self.assertEqual(floatformat(7.0), u'7')
+self.assertEqual(floatformat(0.7), u'0.7')
+self.assertEqual(floatformat(0.07), u'0.1')
+self.assertEqual(floatformat(0.007), u'0.0')
+self.assertEqual(floatformat(0.0), u'0')
+self.assertEqual(floatformat(7.7, 3), u'7.700')
+self.assertEqual(floatformat(6.00, 3), u'6.000')
+self.assertEqual(floatformat(6.20, 3), u'6.200')
+self.assertEqual(floatformat(6.20, -3), u'6.200')
+self.assertEqual(floatformat(13.1031, -3), u'13.103')
+self.assertEqual(floatformat(11.1197, -2), u'11.12')
+self.assertEqual(floatformat(11., -2), u'11')
+self.assertEqual(floatformat(11.01, -2), u'11.00')
+self.assertEqual(floatformat(8.2798, 3), u'8.280')
+self.assertEqual(floatformat(u'foo'), u'')
+self.assertEqual(floatformat(13.1031, u'bar'), u'13.1031')
+self.assertEqual(floatformat(18.125, 2), u'18.13')
+self.assertEqual(floatformat(u'foo', u'bar'), u'')
+self.assertEqual(floatformat(u'¿Cómo esta usted?'), u'')
+self.assertEqual(floatformat(None), u'')
 
->>> addslashes(u'"double quotes" and \'single quotes\'')
-u'\\"double quotes\\" and \\\'single quotes\\\''
+pos_inf = float(1e3)
+self.assertEqual(floatformat(pos_inf), unicode(pos_inf))
 
->>> addslashes(ur'\ : backslashes, too')
-u' : backslashes, too'
+neg_inf = float(-1e3)
+self.assertEqual(floatformat(neg_inf), unicode(neg_inf))
 
->>> capfirst(u'hello world')
-u'Hello world'
+nan = pos_inf / pos_inf
+self.assertEqual(floatformat(nan), unicode(nan))
 
->>> escapejs(u'"double quotes" and \'single quotes\'')
-u'\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027'
+class FloatWrapper(object):
+def __init__(self, value):
+self.value = value
+def __float__(self):
+return self.value
 
->>> escapejs(ur'\ : backslashes, too')
-u'\\u005C : backslashes, too'
+self.assertEqual(floatformat(FloatWrapper(11.01), -2), u'11.00')
 
->>> escapejs(u'and lots of whitespace: \r\n\t\v\f\b')
-u'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008'
+def test_addslashes(self):
+self.assertEqual(addslashes(u'"double quotes" and \'single quotes\''),
+  u'\\"double quotes\\" and \\\'single quotes\\\'')
 
->>> escapejs(ur'and this')
-u'\\u003Cscript\\u003Eand this\\u003C/script\\u003E'
+self.assertEqual(addslashes(ur'\ : backslashes, too'),
+  u' : backslashes, too')
 
->>> escapejs(u'paragraph separator:\u2029and line separator:\u2028')
-u'paragraph separator:\\u2029and line separator:\\u2028'
+def test_capfirst(self):
+self.assertEqual(capfirst(u'hello world'), u'Hello world')
 
->>> fix_ampersands(u'Jack & Jill & Jeroboam')
-u'Jack  

[Changeset] r13936 - in django/trunk/tests/regressiontests: datastructures utils

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:18:39 -0500 (Tue, 28 Sep 2010)
New Revision: 13936

Removed:
   django/trunk/tests/regressiontests/datastructures/__init__.py
   django/trunk/tests/regressiontests/datastructures/models.py
   django/trunk/tests/regressiontests/datastructures/tests.py
Modified:
   django/trunk/tests/regressiontests/utils/datastructures.py
Log:
Migrated regressiontest/datastructures doctest, and moved it into the existing 
utils datastructures package. Thanks to Stephan Jaekel.

Deleted: django/trunk/tests/regressiontests/datastructures/__init__.py
===

Deleted: django/trunk/tests/regressiontests/datastructures/models.py
===

Deleted: django/trunk/tests/regressiontests/datastructures/tests.py
===
--- django/trunk/tests/regressiontests/datastructures/tests.py  2010-09-28 
08:18:12 UTC (rev 13935)
+++ django/trunk/tests/regressiontests/datastructures/tests.py  2010-09-28 
08:18:39 UTC (rev 13936)
@@ -1,173 +0,0 @@
-"""
-# Tests for stuff in django.utils.datastructures.
-
->>> import pickle
->>> from django.utils.datastructures import *
-
-### MergeDict #
-
->>> d1 = 
{'chris':'cool','camri':'cute','cotton':'adorable','tulip':'snuggable', 
'twoofme':'firstone'}
->>> d2 = 
{'chris2':'cool2','camri2':'cute2','cotton2':'adorable2','tulip2':'snuggable2'}
->>> d3 = 
{'chris3':'cool3','camri3':'cute3','cotton3':'adorable3','tulip3':'snuggable3'}
->>> d4 = {'twoofme':'secondone'}
->>> md = MergeDict( d1,d2,d3 )
->>> md['chris']
-'cool'
->>> md['camri']
-'cute'
->>> md['twoofme']
-'firstone'
->>> md2 = md.copy()
->>> md2['chris']
-'cool'
-
-MergeDict can merge MultiValueDicts
->>> multi1 = MultiValueDict({'key1': ['value1'], 'key2': ['value2', 'value3']})
->>> multi2 = MultiValueDict({'key2': ['value4'], 'key4': ['value5', 'value6']})
->>> mm = MergeDict(multi1, multi2)
-
-# Although 'key2' appears in both dictionaries, only the first value is used.
->>> mm.getlist('key2')
-['value2', 'value3']
->>> mm.getlist('key4')
-['value5', 'value6']
->>> mm.getlist('undefined')
-[]
-
->>> sorted(mm.keys())
-['key1', 'key2', 'key4']
->>> len(mm.values())
-3
->>> "value1" in mm.values()
-True
->>> sorted(mm.items(), key=lambda k: k[0])
-[('key1', 'value1'), ('key2', 'value3'), ('key4', 'value6')]
->>> [(k,mm.getlist(k)) for k in sorted(mm)]
-[('key1', ['value1']), ('key2', ['value2', 'value3']), ('key4', ['value5', 
'value6'])]
-
-### MultiValueDict ##
-
->>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': 
['Developer']})
->>> d['name']
-'Simon'
->>> d.get('name')
-'Simon'
->>> d.getlist('name')
-['Adrian', 'Simon']
->>> list(d.iteritems())
-[('position', 'Developer'), ('name', 'Simon')]
->>> list(d.iterlists())
-[('position', ['Developer']), ('name', ['Adrian', 'Simon'])]
->>> d['lastname']
-Traceback (most recent call last):
-...
-MultiValueDictKeyError: "Key 'lastname' not found in "
->>> d.get('lastname')
-
->>> d.get('lastname', 'nonexistent')
-'nonexistent'
->>> d.getlist('lastname')
-[]
->>> d.setlist('lastname', ['Holovaty', 'Willison'])
->>> d.getlist('lastname')
-['Holovaty', 'Willison']
->>> d.values()
-['Developer', 'Simon', 'Willison']
->>> list(d.itervalues())
-['Developer', 'Simon', 'Willison']
-
-### SortedDict 
#
-
->>> d = SortedDict()
->>> d['one'] = 'one'
->>> d['two'] = 'two'
->>> d['three'] = 'three'
->>> d['one']
-'one'
->>> d['two']
-'two'
->>> d['three']
-'three'
->>> d.keys()
-['one', 'two', 'three']
->>> d.values()
-['one', 'two', 'three']
->>> d['one'] = 'not one'
->>> d['one']
-'not one'
->>> d.keys() == d.copy().keys()
-True
->>> d2 = d.copy()
->>> d2['four'] = 'four'
->>> print repr(d)
-{'one': 'not one', 'two': 'two', 'three': 'three'}
->>> d.pop('one', 'missing')
-'not one'
->>> d.pop('one', 'missing')
-'missing'
-
->>> SortedDict((i, i) for i in xrange(3))
-{0: 0, 1: 1, 2: 2}
-
-We don't know which item will be popped in popitem(), so we'll just check that
-the number of keys has decreased.
->>> l = len(d)
->>> _ = d.popitem()
->>> l - len(d)
-1
-
-Init from sequence of tuples
->>> d = SortedDict((
-... (1, "one"),
-... (0, "zero"),
-... (2, "two")))
->>> print repr(d)
-{1: 'one', 0: 'zero', 2: 'two'}
-
->>> pickle.loads(pickle.dumps(d, 2))
-{1: 'one', 0: 'zero', 2: 'two'}
-
->>> d.clear()
->>> d
-{}
->>> d.keyOrder
-[]
-
-### DotExpandedDict ##
-
->>> d = DotExpandedDict({'person.1.firstname': ['Simon'], 'person.1.lastname': 
['Willison'], 'person.2.firstname': ['Adrian'], 'person.2.lastname': 
['Holovaty']})
->>> d['person']['1']['lastname']
-['Willison']
->>> d['person']['2']['lastname']
-['Holovaty']
->>> d['person']['2']['firstname']

[Changeset] r13935 - django/trunk/tests/regressiontests/utils

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:18:12 -0500 (Tue, 28 Sep 2010)
New Revision: 13935

Modified:
   django/trunk/tests/regressiontests/utils/checksums.py
   django/trunk/tests/regressiontests/utils/datastructures.py
   django/trunk/tests/regressiontests/utils/dateformat.py
   django/trunk/tests/regressiontests/utils/datetime_safe.py
   django/trunk/tests/regressiontests/utils/feedgenerator.py
   django/trunk/tests/regressiontests/utils/functional.py
   django/trunk/tests/regressiontests/utils/html.py
   django/trunk/tests/regressiontests/utils/module_loading.py
   django/trunk/tests/regressiontests/utils/simplelazyobject.py
   django/trunk/tests/regressiontests/utils/termcolors.py
   django/trunk/tests/regressiontests/utils/text.py
   django/trunk/tests/regressiontests/utils/timesince.py
   django/trunk/tests/regressiontests/utils/tzinfo.py
Log:
A few test optimizations; using native unittest where no Django-specific 
TestCase features are required.

Modified: django/trunk/tests/regressiontests/utils/checksums.py
===
--- django/trunk/tests/regressiontests/utils/checksums.py   2010-09-28 
08:17:36 UTC (rev 13934)
+++ django/trunk/tests/regressiontests/utils/checksums.py   2010-09-28 
08:18:12 UTC (rev 13935)
@@ -1,8 +1,8 @@
-from django.test import TestCase
+import unittest
 
 from django.utils import checksums
 
-class TestUtilsChecksums(TestCase):
+class TestUtilsChecksums(unittest.TestCase):
 
 def check_output(self, function, value, output=None):
 """

Modified: django/trunk/tests/regressiontests/utils/datastructures.py
===
--- django/trunk/tests/regressiontests/utils/datastructures.py  2010-09-28 
08:17:36 UTC (rev 13934)
+++ django/trunk/tests/regressiontests/utils/datastructures.py  2010-09-28 
08:18:12 UTC (rev 13935)
@@ -1,7 +1,8 @@
-from django.test import TestCase
+import unittest
+
 from django.utils.datastructures import SortedDict
 
-class DatastructuresTests(TestCase):
+class DatastructuresTests(unittest.TestCase):
 def setUp(self):
 self.d1 = SortedDict()
 self.d1[7] = 'seven'

Modified: django/trunk/tests/regressiontests/utils/dateformat.py
===
--- django/trunk/tests/regressiontests/utils/dateformat.py  2010-09-28 
08:17:36 UTC (rev 13934)
+++ django/trunk/tests/regressiontests/utils/dateformat.py  2010-09-28 
08:18:12 UTC (rev 13935)
@@ -1,10 +1,11 @@
+from datetime import datetime, date
 import os
-from unittest import TestCase
-from datetime import datetime, date
+import unittest
+
 from django.utils.dateformat import format
 from django.utils.tzinfo import FixedOffset, LocalTimezone
 
-class DateFormatTests(TestCase):
+class DateFormatTests(unittest.TestCase):
 def test_date(self):
 d = date(2009, 5, 16)
 self.assertEquals(date.fromtimestamp(int(format(d, 'U'))), d)

Modified: django/trunk/tests/regressiontests/utils/datetime_safe.py
===
--- django/trunk/tests/regressiontests/utils/datetime_safe.py   2010-09-28 
08:17:36 UTC (rev 13934)
+++ django/trunk/tests/regressiontests/utils/datetime_safe.py   2010-09-28 
08:18:12 UTC (rev 13935)
@@ -1,9 +1,9 @@
-from django.test import TestCase
+import unittest
 
 from datetime import date as original_date, datetime as original_datetime
 from django.utils.datetime_safe import date, datetime
 
-class DatetimeTests(TestCase):
+class DatetimeTests(unittest.TestCase):
 
 def setUp(self):
 self.just_safe = (1900, 1, 1)

Modified: django/trunk/tests/regressiontests/utils/feedgenerator.py
===
--- django/trunk/tests/regressiontests/utils/feedgenerator.py   2010-09-28 
08:17:36 UTC (rev 13934)
+++ django/trunk/tests/regressiontests/utils/feedgenerator.py   2010-09-28 
08:18:12 UTC (rev 13935)
@@ -1,9 +1,9 @@
 import datetime
-from unittest import TestCase
+import unittest
 
 from django.utils import feedgenerator, tzinfo
 
-class FeedgeneratorTest(TestCase):
+class FeedgeneratorTest(unittest.TestCase):
 """
 Tests for the low-level syndication feed framework.
 """

Modified: django/trunk/tests/regressiontests/utils/functional.py
===
--- django/trunk/tests/regressiontests/utils/functional.py  2010-09-28 
08:17:36 UTC (rev 13934)
+++ django/trunk/tests/regressiontests/utils/functional.py  2010-09-28 
08:18:12 UTC (rev 13935)
@@ -1,9 +1,9 @@
-from unittest import TestCase
+import unittest
 
 from django.utils.functional import lazy
 
 
-class FunctionalTestCase(TestCase):
+class FunctionalTestCase(unittest.TestCase):
 def test_lazy(self):
 t = lazy(lambda: tuple(range(3)), list, tuple)
 for a, b in zip(t(), range(3)):

Modified: 

[Changeset] r13934 - django/trunk/tests/regressiontests/null_fk

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:17:36 -0500 (Tue, 28 Sep 2010)
New Revision: 13934

Added:
   django/trunk/tests/regressiontests/null_fk/tests.py
Modified:
   django/trunk/tests/regressiontests/null_fk/models.py
Log:
Migrated null_fk doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/null_fk/models.py
===
--- django/trunk/tests/regressiontests/null_fk/models.py2010-09-28 
08:17:12 UTC (rev 13933)
+++ django/trunk/tests/regressiontests/null_fk/models.py2010-09-28 
08:17:36 UTC (rev 13934)
@@ -31,37 +31,3 @@
 
 def __unicode__(self):
 return self.comment_text
-
-__test__ = {'API_TESTS':"""
-
->>> d = SystemDetails.objects.create(details='First details')
->>> s = SystemInfo.objects.create(system_name='First forum', system_details=d)
->>> f = Forum.objects.create(system_info=s, forum_name='First forum')
->>> p = Post.objects.create(forum=f, title='First Post')
->>> c1 = Comment.objects.create(post=p, comment_text='My first comment')
->>> c2 = Comment.objects.create(comment_text='My second comment')
-
-# Starting from comment, make sure that a .select_related(...) with a specified
-# set of fields will properly LEFT JOIN multiple levels of NULLs (and the 
things
-# that come after the NULLs, or else data that should exist won't). Regression
-# test for #7369.
->>> c = Comment.objects.select_related().get(id=1)
->>> c.post
-
->>> c = Comment.objects.select_related().get(id=2)
->>> print c.post
-None
-
->>> comments = Comment.objects.select_related('post__forum__system_info').all()
->>> [(c.id, c.comment_text, c.post) for c in comments]
-[(1, u'My first comment', ), (2, u'My second comment', None)]
-
-# Regression test for #7530, #7716.
->>> Comment.objects.select_related('post').filter(post__isnull=True)[0].post 
is None
-True
-
->>> comments = 
Comment.objects.select_related('post__forum__system_info__system_details')
->>> [(c.id, c.comment_text, c.post) for c in comments]
-[(1, u'My first comment', ), (2, u'My second comment', None)]
-
-"""}

Added: django/trunk/tests/regressiontests/null_fk/tests.py
===
--- django/trunk/tests/regressiontests/null_fk/tests.py 
(rev 0)
+++ django/trunk/tests/regressiontests/null_fk/tests.py 2010-09-28 08:17:36 UTC 
(rev 13934)
@@ -0,0 +1,42 @@
+from django.test import TestCase
+
+from regressiontests.null_fk.models import *
+
+class NullFkTests(TestCase):
+
+def test_null_fk(self):
+d = SystemDetails.objects.create(details='First details')
+s = SystemInfo.objects.create(system_name='First forum', 
system_details=d)
+f = Forum.objects.create(system_info=s, forum_name='First forum')
+p = Post.objects.create(forum=f, title='First Post')
+c1 = Comment.objects.create(post=p, comment_text='My first comment')
+c2 = Comment.objects.create(comment_text='My second comment')
+
+# Starting from comment, make sure that a .select_related(...) with a 
specified
+# set of fields will properly LEFT JOIN multiple levels of NULLs (and 
the things
+# that come after the NULLs, or else data that should exist won't). 
Regression
+# test for #7369.
+c = Comment.objects.select_related().get(id=1)
+self.assertEquals(c.post, p)
+self.assertEquals(Comment.objects.select_related().get(id=2).post, 
None)
+
+self.assertQuerysetEqual(
+Comment.objects.select_related('post__forum__system_info').all(),
+[
+(1, u'My first comment', ''),
+(2, u'My second comment', 'None')
+],
+transform = lambda c: (c.id, c.comment_text, repr(c.post))
+)
+
+# Regression test for #7530, #7716.
+
self.assertTrue(Comment.objects.select_related('post').filter(post__isnull=True)[0].post
 is None)
+
+self.assertQuerysetEqual(
+
Comment.objects.select_related('post__forum__system_info__system_details'),
+[
+(1, u'My first comment', ''),
+(2, u'My second comment', 'None')
+],
+transform = lambda c: (c.id, c.comment_text, repr(c.post))
+)

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



[Changeset] r13933 - django/trunk/tests/regressiontests/null_fk_ordering

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:17:12 -0500 (Tue, 28 Sep 2010)
New Revision: 13933

Added:
   django/trunk/tests/regressiontests/null_fk_ordering/tests.py
Modified:
   django/trunk/tests/regressiontests/null_fk_ordering/models.py
Log:
Migrated null_fk_ordering doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/null_fk_ordering/models.py
===
--- django/trunk/tests/regressiontests/null_fk_ordering/models.py   
2010-09-28 08:16:47 UTC (rev 13932)
+++ django/trunk/tests/regressiontests/null_fk_ordering/models.py   
2010-09-28 08:17:12 UTC (rev 13933)
@@ -47,40 +47,3 @@
 
 def __unicode__(self):
 return self.comment_text
-
-
-__test__ = {'API_TESTS': """
-# Regression test for #7512 -- ordering across nullable Foreign Keys shouldn't
-# exclude results
->>> author_1 = Author.objects.create(name='Tom Jones')
->>> author_2 = Author.objects.create(name='Bob Smith')
->>> article_1 = Article.objects.create(title='No author on this article')
->>> article_2 = Article.objects.create(author=author_1, title='This article 
written by Tom Jones')
->>> article_3 = Article.objects.create(author=author_2, title='This article 
written by Bob Smith')
-
-# We can't compare results directly (since different databases sort NULLs to
-# different ends of the ordering), but we can check that all results are
-# returned.
->>> len(list(Article.objects.all())) == 3
-True
-
->>> s = SystemInfo.objects.create(system_name='System Info')
->>> f = Forum.objects.create(system_info=s, forum_name='First forum')
->>> p = Post.objects.create(forum=f, title='First Post')
->>> c1 = Comment.objects.create(post=p, comment_text='My first comment')
->>> c2 = Comment.objects.create(comment_text='My second comment')
->>> s2 = SystemInfo.objects.create(system_name='More System Info')
->>> f2 = Forum.objects.create(system_info=s2, forum_name='Second forum')
->>> p2 = Post.objects.create(forum=f2, title='Second Post')
->>> c3 = Comment.objects.create(comment_text='Another first comment')
->>> c4 = Comment.objects.create(post=p2, comment_text='Another second comment')
-
-# We have to test this carefully. Some databases sort NULL values before
-# everything else, some sort them afterwards. So we extract the ordered list
-# and check the length. Before the fix, this list was too short (some values
-# were omitted).
->>> len(list(Comment.objects.all())) == 4
-True
-
-"""
-}

Added: django/trunk/tests/regressiontests/null_fk_ordering/tests.py
===
--- django/trunk/tests/regressiontests/null_fk_ordering/tests.py
(rev 0)
+++ django/trunk/tests/regressiontests/null_fk_ordering/tests.py
2010-09-28 08:17:12 UTC (rev 13933)
@@ -0,0 +1,39 @@
+from django.test import TestCase
+
+from regressiontests.null_fk_ordering.models import *
+
+class NullFkOrderingTests(TestCase):
+
+def test_ordering_across_null_fk(self):
+"""
+Regression test for #7512
+
+ordering across nullable Foreign Keys shouldn't exclude results
+"""
+author_1 = Author.objects.create(name='Tom Jones')
+author_2 = Author.objects.create(name='Bob Smith')
+article_1 = Article.objects.create(title='No author on this article')
+article_2 = Article.objects.create(author=author_1, title='This 
article written by Tom Jones')
+article_3 = Article.objects.create(author=author_2, title='This 
article written by Bob Smith')
+
+# We can't compare results directly (since different databases sort 
NULLs to
+# different ends of the ordering), but we can check that all results 
are
+# returned.
+self.assertTrue(len(list(Article.objects.all())) == 3)
+
+s = SystemInfo.objects.create(system_name='System Info')
+f = Forum.objects.create(system_info=s, forum_name='First forum')
+p = Post.objects.create(forum=f, title='First Post')
+c1 = Comment.objects.create(post=p, comment_text='My first comment')
+c2 = Comment.objects.create(comment_text='My second comment')
+s2 = SystemInfo.objects.create(system_name='More System Info')
+f2 = Forum.objects.create(system_info=s2, forum_name='Second forum')
+p2 = Post.objects.create(forum=f2, title='Second Post')
+c3 = Comment.objects.create(comment_text='Another first comment')
+c4 = Comment.objects.create(post=p2, comment_text='Another second 
comment')
+
+# We have to test this carefully. Some databases sort NULL values 
before
+# everything else, some sort them afterwards. So we extract the 
ordered list
+# and check the length. Before the fix, this list was too short (some 
values
+# were omitted).
+self.assertTrue(len(list(Comment.objects.all())) == 4)

-- 
You received this message because you are subscribed to the Google Groups 
"Django 

[Changeset] r13932 - django/trunk/tests/regressiontests/null_queries

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:16:47 -0500 (Tue, 28 Sep 2010)
New Revision: 13932

Added:
   django/trunk/tests/regressiontests/null_queries/tests.py
Modified:
   django/trunk/tests/regressiontests/null_queries/models.py
Log:
Migrated null_queries doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/null_queries/models.py
===
--- django/trunk/tests/regressiontests/null_queries/models.py   2010-09-28 
08:16:23 UTC (rev 13931)
+++ django/trunk/tests/regressiontests/null_queries/models.py   2010-09-28 
08:16:47 UTC (rev 13932)
@@ -23,60 +23,3 @@
 class Inner(models.Model):
 first = models.ForeignKey(OuterA)
 second = models.ForeignKey(OuterB, null=True)
-
-__test__ = {'API_TESTS':"""
-# Regression test for the use of None as a query value. None is interpreted as
-# an SQL NULL, but only in __exact queries.
-# Set up some initial polls and choices
->>> p1 = Poll(question='Why?')
->>> p1.save()
->>> c1 = Choice(poll=p1, choice='Because.')
->>> c1.save()
->>> c2 = Choice(poll=p1, choice='Why Not?')
->>> c2.save()
-
-# Exact query with value None returns nothing ("is NULL" in sql, but every 'id'
-# field has a value).
->>> Choice.objects.filter(choice__exact=None)
-[]
-
-Excluding the previous result returns everything.
->>> Choice.objects.exclude(choice=None).order_by('id')
-[, ]
-
-# Valid query, but fails because foo isn't a keyword
->>> Choice.objects.filter(foo__exact=None)
-Traceback (most recent call last):
-...
-FieldError: Cannot resolve keyword 'foo' into field. Choices are: choice, id, 
poll
-
-# Can't use None on anything other than __exact
->>> Choice.objects.filter(id__gt=None)
-Traceback (most recent call last):
-...
-ValueError: Cannot use None as a query value
-
-# Can't use None on anything other than __exact
->>> Choice.objects.filter(foo__gt=None)
-Traceback (most recent call last):
-...
-ValueError: Cannot use None as a query value
-
-# Related managers use __exact=None implicitly if the object hasn't been saved.
->>> p2 = Poll(question="How?")
->>> p2.choice_set.all()
-[]
-
-# Querying across reverse relations and then another relation should insert
-# outer joins correctly so as not to exclude results.
->>> obj = OuterA.objects.create()
->>> OuterA.objects.filter(inner__second=None)
-[]
->>> OuterA.objects.filter(inner__second__data=None)
-[]
->>> _ = Inner.objects.create(first=obj)
->>> Inner.objects.filter(first__inner__second=None)
-[]
-
-
-"""}

Added: django/trunk/tests/regressiontests/null_queries/tests.py
===
--- django/trunk/tests/regressiontests/null_queries/tests.py
(rev 0)
+++ django/trunk/tests/regressiontests/null_queries/tests.py2010-09-28 
08:16:47 UTC (rev 13932)
@@ -0,0 +1,69 @@
+from django.test import TestCase
+from django.core.exceptions import FieldError
+
+from regressiontests.null_queries.models import *
+
+
+class NullQueriesTests(TestCase):
+
+def test_none_as_null(self):
+"""
+Regression test for the use of None as a query value.
+
+None is interpreted as an SQL NULL, but only in __exact queries.
+Set up some initial polls and choices
+"""
+p1 = Poll(question='Why?')
+p1.save()
+c1 = Choice(poll=p1, choice='Because.')
+c1.save()
+c2 = Choice(poll=p1, choice='Why Not?')
+c2.save()
+
+# Exact query with value None returns nothing ("is NULL" in sql,
+# but every 'id' field has a value).
+self.assertQuerysetEqual(Choice.objects.filter(choice__exact=None), [])
+
+# Excluding the previous result returns everything.
+self.assertQuerysetEqual(
+Choice.objects.exclude(choice=None).order_by('id'),
+[
+'',
+''
+]
+)
+
+# Valid query, but fails because foo isn't a keyword
+self.assertRaises(FieldError, Choice.objects.filter, foo__exact=None)
+
+# Can't use None on anything other than __exact
+self.assertRaises(ValueError, Choice.objects.filter, id__gt=None)
+
+# Can't use None on anything other than __exact
+self.assertRaises(ValueError, Choice.objects.filter, foo__gt=None)
+
+# Related managers use __exact=None implicitly if the object hasn't 
been saved.
+p2 = Poll(question="How?")
+self.assertEquals(repr(p2.choice_set.all()), '[]')
+
+def test_reverse_relations(self):
+"""
+Querying across reverse relations and then another relation should
+insert outer joins correctly so as not to exclude results.
+"""
+obj = OuterA.objects.create()
+self.assertQuerysetEqual(
+OuterA.objects.filter(inner__second=None),
+['']
+)
+self.assertQuerysetEqual(
+

[Changeset] r13931 - django/trunk/tests/regressiontests/one_to_one_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 03:16:23 -0500 (Tue, 28 Sep 2010)
New Revision: 13931

Modified:
   django/trunk/tests/regressiontests/one_to_one_regress/models.py
   django/trunk/tests/regressiontests/one_to_one_regress/tests.py
Log:
Migrated one_to_one_regress doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/one_to_one_regress/models.py
===
--- django/trunk/tests/regressiontests/one_to_one_regress/models.py 
2010-09-28 07:10:05 UTC (rev 13930)
+++ django/trunk/tests/regressiontests/one_to_one_regress/models.py 
2010-09-28 08:16:23 UTC (rev 13931)
@@ -41,104 +41,3 @@
 
 class Pointer2(models.Model):
 other = models.OneToOneField(Target)
-
-__test__ = {'API_TESTS':"""
-# Regression test for #1064 and #1506: Check that we create models via the m2m
-# relation if the remote model has a OneToOneField.
->>> p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
->>> p1.save()
->>> r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False)
->>> r.save()
->>> f = Favorites(name = 'Fred')
->>> f.save()
->>> f.restaurants = [r]
->>> f.restaurants.all()
-[]
-
-# Regression test for #7173: Check that the name of the cache for the
-# reverse object is correct.
->>> b = Bar(place=p1, serves_cocktails=False)
->>> b.save()
->>> p1.restaurant
-
->>> p1.bar
-
-
-#
-# Regression test for #6886 (the related-object cache)
-#
-
-# Look up the objects again so that we get "fresh" objects
->>> p = Place.objects.get(name="Demon Dogs")
->>> r = p.restaurant
-
-# Accessing the related object again returns the exactly same object
->>> p.restaurant is r
-True
-
-# But if we kill the cache, we get a new object
->>> del p._restaurant_cache
->>> p.restaurant is r
-False
-
-# Reassigning the Restaurant object results in an immediate cache update
-# We can't use a new Restaurant because that'll violate one-to-one, but
-# with a new *instance* the is test below will fail if #6886 regresses.
->>> r2 = Restaurant.objects.get(pk=r.pk)
->>> p.restaurant = r2
->>> p.restaurant is r2
-True
-
-# Assigning None succeeds if field is null=True.
->>> ug_bar = UndergroundBar.objects.create(place=p, serves_cocktails=False)
->>> ug_bar.place = None
->>> ug_bar.place is None
-True
-
-# Assigning None fails: Place.restaurant is null=False
->>> p.restaurant = None
-Traceback (most recent call last):
-...
-ValueError: Cannot assign None: "Place.restaurant" does not allow null values.
-
-# You also can't assign an object of the wrong type here
->>> p.restaurant = p
-Traceback (most recent call last):
-...
-ValueError: Cannot assign "": "Place.restaurant" 
must be a "Restaurant" instance.
-
-# Creation using keyword argument should cache the related object.
->>> p = Place.objects.get(name="Demon Dogs")
->>> r = Restaurant(place=p)
->>> r.place is p
-True
-
-# Creation using keyword argument and unsaved related instance (#8070).
->>> p = Place()
->>> r = Restaurant(place=p)
->>> r.place is p
-True
-
-# Creation using attname keyword argument and an id will cause the related
-# object to be fetched.
->>> p = Place.objects.get(name="Demon Dogs")
->>> r = Restaurant(place_id=p.id)
->>> r.place is p
-False
->>> r.place == p
-True
-
-# Regression test for #9968: filtering reverse one-to-one relations with
-# primary_key=True was misbehaving. We test both (primary_key=True & False)
-# cases here to prevent any reappearance of the problem.
->>> _ = Target.objects.create()
->>> Target.objects.filter(pointer=None)
-[]
->>> Target.objects.exclude(pointer=None)
-[]
->>> Target.objects.filter(pointer2=None)
-[]
->>> Target.objects.exclude(pointer2=None)
-[]
-
-"""}

Modified: django/trunk/tests/regressiontests/one_to_one_regress/tests.py
===
--- django/trunk/tests/regressiontests/one_to_one_regress/tests.py  
2010-09-28 07:10:05 UTC (rev 13930)
+++ django/trunk/tests/regressiontests/one_to_one_regress/tests.py  
2010-09-28 08:16:23 UTC (rev 13931)
@@ -1,22 +1,130 @@
 from django.test import TestCase
-from regressiontests.one_to_one_regress.models import Place, UndergroundBar
+from regressiontests.one_to_one_regress.models import *
 
-class OneToOneDeletionTests(TestCase):
+class OneToOneRegressionTests(TestCase):
+
+def setUp(self):
+self.p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
+self.p1.save()
+self.r1 = Restaurant(place=self.p1, serves_hot_dogs=True, 
serves_pizza=False)
+self.r1.save()
+self.b1 = Bar(place=self.p1, serves_cocktails=False)
+self.b1.save()
+
 def test_reverse_relationship_cache_cascade(self):
 """
 Regression test for #9023: accessing the reverse relationship shouldn't
 result in a cascading delete().
 """
-place = Place.objects.create(name="Dempsey's", address="623 Vermont 
St")
-bar = UndergroundBar.objects.create(place=place, 

[Changeset] r13930 - django/branches/releases/1.2.X/tests/regressiontests/requests

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 02:10:05 -0500 (Tue, 28 Sep 2010)
New Revision: 13930

Modified:
   django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py
Log:
[1.2.X] Migrated requests doctests. Thanks to Stephan Jaekel.

Backport of r13927 from trunk.

Modified: django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py
===
--- django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py  
2010-09-28 07:09:40 UTC (rev 13929)
+++ django/branches/releases/1.2.X/tests/regressiontests/requests/tests.py  
2010-09-28 07:10:05 UTC (rev 13930)
@@ -1,47 +1,61 @@
-"""
->>> from django.http import HttpRequest
->>> print repr(HttpRequest())
-
+from datetime import datetime, timedelta
+import time
+import unittest
 
->>> from django.core.handlers.wsgi import WSGIRequest
->>> print repr(WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 'bogus'}))
-,
-POST:,
-COOKIES:{},
-META:{...}>
+from django.http import HttpRequest, HttpResponse, parse_cookie
+from django.core.handlers.wsgi import WSGIRequest
+from django.core.handlers.modpython import ModPythonRequest
+from django.utils.http import cookie_date
 
->>> from django.core.handlers.modpython import ModPythonRequest
->>> class FakeModPythonRequest(ModPythonRequest):
-...def __init__(self, *args, **kwargs):
-...super(FakeModPythonRequest, self).__init__(*args, **kwargs)
-...self._get = self._post = self._meta = self._cookies = {}
->>> class Dummy:
-... def get_options(self):
-... return {}
->>> req = Dummy()
->>> req.uri = 'bogus'
->>> print repr(FakeModPythonRequest(req))
-
+class RequestsTests(unittest.TestCase):
 
->>> from django.http import parse_cookie
->>> parse_cookie('invalid:key=true')
-{}
+def test_httprequest(self):
+self.assertEquals(repr(HttpRequest()),
+""
+)
 
->>> request = HttpRequest()
->>> print request.build_absolute_uri(location="https://www.example.com/asdf;)
-https://www.example.com/asdf
->>> request.get_host = lambda: 'www.example.com'
->>> request.path = ''
->>> print request.build_absolute_uri(location="/path/with:colons")
-http://www.example.com/path/with:colons
-"""
+def test_wsgirequest(self):
+self.assertEquals(repr(WSGIRequest({'PATH_INFO': 'bogus', 
'REQUEST_METHOD': 'bogus'})),
+""
+)
+
+def test_modpythonrequest(self):
+class FakeModPythonRequest(ModPythonRequest):
+   def __init__(self, *args, **kwargs):
+   super(FakeModPythonRequest, self).__init__(*args, **kwargs)
+   self._get = self._post = self._meta = self._cookies = {}
+
+class Dummy:
+def get_options(self):
+return {}
+
+req = Dummy()
+req.uri = 'bogus'
+self.assertEquals(repr(FakeModPythonRequest(req)),
+"")
+
+def test_parse_cookie(self):
+self.assertEquals(parse_cookie('invalid:key=true'), {})
+
+def test_httprequest_location(self):
+request = HttpRequest()
+
self.assertEquals(request.build_absolute_uri(location="https://www.example.com/asdf;),
+'https://www.example.com/asdf')
+
+request.get_host = lambda: 'www.example.com'
+request.path = ''
+
self.assertEquals(request.build_absolute_uri(location="/path/with:colons"),
+'http://www.example.com/path/with:colons')

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



[Changeset] r13929 - django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 02:09:40 -0500 (Tue, 28 Sep 2010)
New Revision: 13929

Added:
   
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/tests.py
Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/models.py
Log:
[1.2.X] Migrated reverse_single_related doctests. Thanks to Stephan Jaekel.

Backport of r13926 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/models.py
   2010-09-28 07:09:19 UTC (rev 13928)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/models.py
   2010-09-28 07:09:40 UTC (rev 13929)
@@ -1,11 +1,5 @@
-"""
-Regression tests for an object that cannot access a single related object due
-to a restrictive default manager.
-"""
-
 from django.db import models
 
-
 class SourceManager(models.Manager):
 def get_query_set(self):
 return super(SourceManager, 
self).get_query_set().filter(is_public=True)
@@ -16,39 +10,3 @@
 
 class Item(models.Model):
 source = models.ForeignKey(Source)
-
-
-__test__ = {'API_TESTS':"""
-
->>> public_source = Source.objects.create(is_public=True)
->>> public_item = Item.objects.create(source=public_source)
-
->>> private_source = Source.objects.create(is_public=False)
->>> private_item = Item.objects.create(source=private_source)
-
-# Only one source is available via all() due to the custom default manager.
-
->>> Source.objects.all()
-[]
-
->>> public_item.source
-
-
-# Make sure that an item can still access its related source even if the 
default
-# manager doesn't normally allow it.
-
->>> private_item.source
-
-
-# If the manager is marked "use_for_related_fields", it'll get used instead
-# of the "bare" queryset. Usually you'd define this as a property on the class,
-# but this approximates that in a way that's easier in tests.
-
->>> Source.objects.use_for_related_fields = True
->>> private_item = Item.objects.get(pk=private_item.pk)
->>> private_item.source
-Traceback (most recent call last):
-...
-DoesNotExist: Source matching query does not exist.
-
-"""}

Added: 
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/tests.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/tests.py
(rev 0)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/reverse_single_related/tests.py
2010-09-28 07:09:40 UTC (rev 13929)
@@ -0,0 +1,36 @@
+from django.test import TestCase
+
+from regressiontests.reverse_single_related.models import *
+
+class ReverseSingleRelatedTests(TestCase):
+"""
+Regression tests for an object that cannot access a single related
+object due to a restrictive default manager.
+"""
+
+def test_reverse_single_related(self):
+
+public_source = Source.objects.create(is_public=True)
+public_item = Item.objects.create(source=public_source)
+
+private_source = Source.objects.create(is_public=False)
+private_item = Item.objects.create(source=private_source)
+
+# Only one source is available via all() due to the custom default 
manager.
+self.assertQuerysetEqual(
+Source.objects.all(),
+[""]
+)
+
+self.assertEquals(public_item.source, public_source)
+
+# Make sure that an item can still access its related source even if 
the default
+# manager doesn't normally allow it.
+self.assertEquals(private_item.source, private_source)
+
+# If the manager is marked "use_for_related_fields", it'll get used 
instead
+# of the "bare" queryset. Usually you'd define this as a property on 
the class,
+# but this approximates that in a way that's easier in tests.
+Source.objects.use_for_related_fields = True
+private_item = Item.objects.get(pk=private_item.pk)
+self.assertRaises(Source.DoesNotExist, lambda: private_item.source)

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



[Changeset] r13928 - django/branches/releases/1.2.X/tests/regressiontests/select_related_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 02:09:19 -0500 (Tue, 28 Sep 2010)
New Revision: 13928

Added:
   
django/branches/releases/1.2.X/tests/regressiontests/select_related_regress/tests.py
Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/select_related_regress/models.py
Log:
[1.2.X] Migrated select_related_regress doctests. Thanks to Stephan Jaekel.

Backport of r13925 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/select_related_regress/models.py
===
--- 
django/branches/releases/1.2.X/tests/regressiontests/select_related_regress/models.py
   2010-09-28 07:06:37 UTC (rev 13927)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/select_related_regress/models.py
   2010-09-28 07:09:19 UTC (rev 13928)
@@ -84,126 +84,3 @@
 
 def __unicode__(self):
 return self.name
-
-__test__ = {'API_TESTS': """
-Regression test for bug #7110. When using select_related(), we must query the
-Device and Building tables using two different aliases (each) in order to
-differentiate the start and end Connection fields. The net result is that both
-the "connections = ..." queries here should give the same results without
-pulling in more than the absolute minimum number of tables (history has
-shown that it's easy to make a mistake in the implementation and include some
-unnecessary bonus joins).
-
->>> b=Building.objects.create(name='101')
->>> dev1=Device.objects.create(name="router", building=b)
->>> dev2=Device.objects.create(name="switch", building=b)
->>> dev3=Device.objects.create(name="server", building=b)
->>> port1=Port.objects.create(port_number='4',device=dev1)
->>> port2=Port.objects.create(port_number='7',device=dev2)
->>> port3=Port.objects.create(port_number='1',device=dev3)
->>> c1=Connection.objects.create(start=port1, end=port2)
->>> c2=Connection.objects.create(start=port2, end=port3)
-
->>> connections=Connection.objects.filter(start__device__building=b, 
end__device__building=b).order_by('id')
->>> [(c.id, unicode(c.start), unicode(c.end)) for c in connections]
-[(1, u'router/4', u'switch/7'), (2, u'switch/7', u'server/1')]
-
->>> connections=Connection.objects.filter(start__device__building=b, 
end__device__building=b).select_related().order_by('id')
->>> [(c.id, unicode(c.start), unicode(c.end)) for c in connections]
-[(1, u'router/4', u'switch/7'), (2, u'switch/7', u'server/1')]
-
-# This final query should only join seven tables (port, device and building
-# twice each, plus connection once).
->>> connections.query.count_active_tables()
-7
-
-Regression test for bug #8106. Same sort of problem as the previous test, but
-this time there are more extra tables to pull in as part of the
-select_related() and some of them could potentially clash (so need to be kept
-separate).
-
->>> us = TUser.objects.create(name="std")
->>> usp = Person.objects.create(user=us)
->>> uo = TUser.objects.create(name="org")
->>> uop = Person.objects.create(user=uo)
->>> s = Student.objects.create(person = usp)
->>> o = Organizer.objects.create(person = uop)
->>> c = Class.objects.create(org=o)
->>> e = Enrollment.objects.create(std=s, cls=c)
-
->>> e_related = Enrollment.objects.all().select_related()[0]
->>> e_related.std.person.user.name
-u"std"
->>> e_related.cls.org.person.user.name
-u"org"
-
-Regression test for bug #8036: the first related model in the tests below
-("state") is empty and we try to select the more remotely related
-state__country. The regression here was not skipping the empty column results
-for country before getting status.
-
->>> australia = Country.objects.create(name='Australia')
->>> active = ClientStatus.objects.create(name='active')
->>> client = Client.objects.create(name='client', status=active)
-
->>> client.status
-
->>> Client.objects.select_related()[0].status
-
->>> Client.objects.select_related('state')[0].status
-
->>> Client.objects.select_related('state', 'status')[0].status
-
->>> Client.objects.select_related('state__country')[0].status
-
->>> Client.objects.select_related('state__country', 'status')[0].status
-
->>> Client.objects.select_related('status')[0].status
-
-
-Exercising select_related() with multi-table model inheritance.
->>> c1 = Child.objects.create(name="child1", value=42)
->>> _ = Item.objects.create(name="item1", child=c1)
->>> _ = Item.objects.create(name="item2")
->>> Item.objects.select_related("child").order_by("name")
-[, ]
-
-# Regression for #12851 - Deferred fields are used correctly if you
-# select_related a subset of fields.
->>> wa = State.objects.create(name="Western Australia", country=australia)
->>> _ = Client.objects.create(name='Brian Burke', state=wa, status=active)
->>> burke = 
Client.objects.select_related('state').defer('state__name').get(name='Brian 
Burke')
->>> burke.name
-u'Brian Burke'
->>> burke.state.name
-u'Western Australia'
-
-# Still works if we're dealing with an inherited class
->>> _ = 

[Changeset] r13927 - django/trunk/tests/regressiontests/requests

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 02:06:37 -0500 (Tue, 28 Sep 2010)
New Revision: 13927

Modified:
   django/trunk/tests/regressiontests/requests/tests.py
Log:
Migrated requests doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/requests/tests.py
===
--- django/trunk/tests/regressiontests/requests/tests.py2010-09-28 
07:06:15 UTC (rev 13926)
+++ django/trunk/tests/regressiontests/requests/tests.py2010-09-28 
07:06:37 UTC (rev 13927)
@@ -1,81 +1,92 @@
-"""
->>> from django.http import HttpRequest, HttpResponse
->>> print repr(HttpRequest())
-
+from datetime import datetime, timedelta
+import time
+import unittest
 
->>> from django.core.handlers.wsgi import WSGIRequest
->>> print repr(WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 'bogus'}))
-,
-POST:,
-COOKIES:{},
-META:{...}>
+from django.http import HttpRequest, HttpResponse, parse_cookie
+from django.core.handlers.wsgi import WSGIRequest
+from django.core.handlers.modpython import ModPythonRequest
+from django.utils.http import cookie_date
 
->>> from django.core.handlers.modpython import ModPythonRequest
->>> class FakeModPythonRequest(ModPythonRequest):
-...def __init__(self, *args, **kwargs):
-...super(FakeModPythonRequest, self).__init__(*args, **kwargs)
-...self._get = self._post = self._meta = self._cookies = {}
->>> class Dummy:
-... def get_options(self):
-... return {}
->>> req = Dummy()
->>> req.uri = 'bogus'
->>> print repr(FakeModPythonRequest(req))
-
+class RequestsTests(unittest.TestCase):
 
->>> from django.http import parse_cookie
->>> parse_cookie('invalid:key=true')
-{}
+def test_httprequest(self):
+self.assertEquals(repr(HttpRequest()),
+""
+)
 
->>> request = HttpRequest()
->>> print request.build_absolute_uri(location="https://www.example.com/asdf;)
-https://www.example.com/asdf
->>> request.get_host = lambda: 'www.example.com'
->>> request.path = ''
->>> print request.build_absolute_uri(location="/path/with:colons")
-http://www.example.com/path/with:colons
+def test_wsgirequest(self):
+self.assertEquals(repr(WSGIRequest({'PATH_INFO': 'bogus', 
'REQUEST_METHOD': 'bogus'})),
+""
+)
 
+def test_modpythonrequest(self):
+class FakeModPythonRequest(ModPythonRequest):
+   def __init__(self, *args, **kwargs):
+   super(FakeModPythonRequest, self).__init__(*args, **kwargs)
+   self._get = self._post = self._meta = self._cookies = {}
 
-# Test cookie datetime expiration logic
->>> from datetime import datetime, timedelta
->>> import time
->>> delta = timedelta(seconds=10)
->>> response = HttpResponse()
->>> expires = datetime.utcnow() + delta
+class Dummy:
+def get_options(self):
+return {}
 
-# There is a timing weakness in this test; The
-# expected result for max-age requires that there be
-# a very slight difference between the evaluated expiration
-# time, and the time evaluated in set_cookie(). If this
-# difference doesn't exist, the cookie time will be
-# 1 second larger. To avoid the problem, put in a quick sleep,
-# which guarantees that there will be a time difference.
->>> time.sleep(0.001)
->>> response.set_cookie('datetime', expires=expires)
->>> datetime_cookie = response.cookies['datetime']
->>> datetime_cookie['max-age']
-10
->>> response.set_cookie('datetime', expires=datetime(2028, 1, 1, 4, 5, 6))
->>> response.cookies['datetime']['expires']
-'Sat, 01-Jan-2028 04:05:06 GMT'
+req = Dummy()
+req.uri = 'bogus'
+self.assertEquals(repr(FakeModPythonRequest(req)),
+"")
 
-# Test automatically setting cookie expires if only max_age is provided
->>> response.set_cookie('max_age', max_age=10)
->>> max_age_cookie = response.cookies['max_age']
->>> max_age_cookie['max-age']
-10
->>> from django.utils.http import cookie_date
->>> import time
->>> max_age_cookie['expires'] == cookie_date(time.time()+10)
-True
-"""
+def test_parse_cookie(self):
+self.assertEquals(parse_cookie('invalid:key=true'), {})
+
+def test_httprequest_location(self):
+request = HttpRequest()
+
self.assertEquals(request.build_absolute_uri(location="https://www.example.com/asdf;),
+'https://www.example.com/asdf')
+
+request.get_host = lambda: 'www.example.com'
+request.path = ''
+

[Changeset] r13926 - django/trunk/tests/regressiontests/reverse_single_related

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 02:06:15 -0500 (Tue, 28 Sep 2010)
New Revision: 13926

Added:
   django/trunk/tests/regressiontests/reverse_single_related/tests.py
Modified:
   django/trunk/tests/regressiontests/reverse_single_related/models.py
Log:
Migrated reverse_single_related doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/reverse_single_related/models.py
===
--- django/trunk/tests/regressiontests/reverse_single_related/models.py 
2010-09-28 07:05:51 UTC (rev 13925)
+++ django/trunk/tests/regressiontests/reverse_single_related/models.py 
2010-09-28 07:06:15 UTC (rev 13926)
@@ -1,11 +1,5 @@
-"""
-Regression tests for an object that cannot access a single related object due
-to a restrictive default manager.
-"""
-
 from django.db import models
 
-
 class SourceManager(models.Manager):
 def get_query_set(self):
 return super(SourceManager, 
self).get_query_set().filter(is_public=True)
@@ -16,39 +10,3 @@
 
 class Item(models.Model):
 source = models.ForeignKey(Source)
-
-
-__test__ = {'API_TESTS':"""
-
->>> public_source = Source.objects.create(is_public=True)
->>> public_item = Item.objects.create(source=public_source)
-
->>> private_source = Source.objects.create(is_public=False)
->>> private_item = Item.objects.create(source=private_source)
-
-# Only one source is available via all() due to the custom default manager.
-
->>> Source.objects.all()
-[]
-
->>> public_item.source
-
-
-# Make sure that an item can still access its related source even if the 
default
-# manager doesn't normally allow it.
-
->>> private_item.source
-
-
-# If the manager is marked "use_for_related_fields", it'll get used instead
-# of the "bare" queryset. Usually you'd define this as a property on the class,
-# but this approximates that in a way that's easier in tests.
-
->>> Source.objects.use_for_related_fields = True
->>> private_item = Item.objects.get(pk=private_item.pk)
->>> private_item.source
-Traceback (most recent call last):
-...
-DoesNotExist: Source matching query does not exist.
-
-"""}

Added: django/trunk/tests/regressiontests/reverse_single_related/tests.py
===
--- django/trunk/tests/regressiontests/reverse_single_related/tests.py  
(rev 0)
+++ django/trunk/tests/regressiontests/reverse_single_related/tests.py  
2010-09-28 07:06:15 UTC (rev 13926)
@@ -0,0 +1,36 @@
+from django.test import TestCase
+
+from regressiontests.reverse_single_related.models import *
+
+class ReverseSingleRelatedTests(TestCase):
+"""
+Regression tests for an object that cannot access a single related
+object due to a restrictive default manager.
+"""
+
+def test_reverse_single_related(self):
+
+public_source = Source.objects.create(is_public=True)
+public_item = Item.objects.create(source=public_source)
+
+private_source = Source.objects.create(is_public=False)
+private_item = Item.objects.create(source=private_source)
+
+# Only one source is available via all() due to the custom default 
manager.
+self.assertQuerysetEqual(
+Source.objects.all(),
+[""]
+)
+
+self.assertEquals(public_item.source, public_source)
+
+# Make sure that an item can still access its related source even if 
the default
+# manager doesn't normally allow it.
+self.assertEquals(private_item.source, private_source)
+
+# If the manager is marked "use_for_related_fields", it'll get used 
instead
+# of the "bare" queryset. Usually you'd define this as a property on 
the class,
+# but this approximates that in a way that's easier in tests.
+Source.objects.use_for_related_fields = True
+private_item = Item.objects.get(pk=private_item.pk)
+self.assertRaises(Source.DoesNotExist, lambda: private_item.source)

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



[Changeset] r13925 - django/trunk/tests/regressiontests/select_related_regress

2010-09-28 Thread noreply
Author: russellm
Date: 2010-09-28 02:05:51 -0500 (Tue, 28 Sep 2010)
New Revision: 13925

Added:
   django/trunk/tests/regressiontests/select_related_regress/tests.py
Modified:
   django/trunk/tests/regressiontests/select_related_regress/models.py
Log:
Migrated select_related_regress doctests. Thanks to Stephan Jaekel.

Modified: django/trunk/tests/regressiontests/select_related_regress/models.py
===
--- django/trunk/tests/regressiontests/select_related_regress/models.py 
2010-09-28 04:49:37 UTC (rev 13924)
+++ django/trunk/tests/regressiontests/select_related_regress/models.py 
2010-09-28 07:05:51 UTC (rev 13925)
@@ -84,126 +84,3 @@
 
 def __unicode__(self):
 return self.name
-
-__test__ = {'API_TESTS': """
-Regression test for bug #7110. When using select_related(), we must query the
-Device and Building tables using two different aliases (each) in order to
-differentiate the start and end Connection fields. The net result is that both
-the "connections = ..." queries here should give the same results without
-pulling in more than the absolute minimum number of tables (history has
-shown that it's easy to make a mistake in the implementation and include some
-unnecessary bonus joins).
-
->>> b=Building.objects.create(name='101')
->>> dev1=Device.objects.create(name="router", building=b)
->>> dev2=Device.objects.create(name="switch", building=b)
->>> dev3=Device.objects.create(name="server", building=b)
->>> port1=Port.objects.create(port_number='4',device=dev1)
->>> port2=Port.objects.create(port_number='7',device=dev2)
->>> port3=Port.objects.create(port_number='1',device=dev3)
->>> c1=Connection.objects.create(start=port1, end=port2)
->>> c2=Connection.objects.create(start=port2, end=port3)
-
->>> connections=Connection.objects.filter(start__device__building=b, 
end__device__building=b).order_by('id')
->>> [(c.id, unicode(c.start), unicode(c.end)) for c in connections]
-[(1, u'router/4', u'switch/7'), (2, u'switch/7', u'server/1')]
-
->>> connections=Connection.objects.filter(start__device__building=b, 
end__device__building=b).select_related().order_by('id')
->>> [(c.id, unicode(c.start), unicode(c.end)) for c in connections]
-[(1, u'router/4', u'switch/7'), (2, u'switch/7', u'server/1')]
-
-# This final query should only join seven tables (port, device and building
-# twice each, plus connection once).
->>> connections.query.count_active_tables()
-7
-
-Regression test for bug #8106. Same sort of problem as the previous test, but
-this time there are more extra tables to pull in as part of the
-select_related() and some of them could potentially clash (so need to be kept
-separate).
-
->>> us = TUser.objects.create(name="std")
->>> usp = Person.objects.create(user=us)
->>> uo = TUser.objects.create(name="org")
->>> uop = Person.objects.create(user=uo)
->>> s = Student.objects.create(person = usp)
->>> o = Organizer.objects.create(person = uop)
->>> c = Class.objects.create(org=o)
->>> e = Enrollment.objects.create(std=s, cls=c)
-
->>> e_related = Enrollment.objects.all().select_related()[0]
->>> e_related.std.person.user.name
-u"std"
->>> e_related.cls.org.person.user.name
-u"org"
-
-Regression test for bug #8036: the first related model in the tests below
-("state") is empty and we try to select the more remotely related
-state__country. The regression here was not skipping the empty column results
-for country before getting status.
-
->>> australia = Country.objects.create(name='Australia')
->>> active = ClientStatus.objects.create(name='active')
->>> client = Client.objects.create(name='client', status=active)
-
->>> client.status
-
->>> Client.objects.select_related()[0].status
-
->>> Client.objects.select_related('state')[0].status
-
->>> Client.objects.select_related('state', 'status')[0].status
-
->>> Client.objects.select_related('state__country')[0].status
-
->>> Client.objects.select_related('state__country', 'status')[0].status
-
->>> Client.objects.select_related('status')[0].status
-
-
-Exercising select_related() with multi-table model inheritance.
->>> c1 = Child.objects.create(name="child1", value=42)
->>> _ = Item.objects.create(name="item1", child=c1)
->>> _ = Item.objects.create(name="item2")
->>> Item.objects.select_related("child").order_by("name")
-[, ]
-
-# Regression for #12851 - Deferred fields are used correctly if you
-# select_related a subset of fields.
->>> wa = State.objects.create(name="Western Australia", country=australia)
->>> _ = Client.objects.create(name='Brian Burke', state=wa, status=active)
->>> burke = 
Client.objects.select_related('state').defer('state__name').get(name='Brian 
Burke')
->>> burke.name
-u'Brian Burke'
->>> burke.state.name
-u'Western Australia'
-
-# Still works if we're dealing with an inherited class
->>> _ = SpecialClient.objects.create(name='Troy Buswell', state=wa, 
status=active, value=42)
->>> troy =