Index: tests/regressiontests/generic_views/dates.py
===================================================================
--- tests/regressiontests/generic_views/dates.py	(revision 14678)
+++ tests/regressiontests/generic_views/dates.py	(working copy)
@@ -1,5 +1,6 @@
 import datetime
 import random
+import itertools
 
 from django.core.exceptions import ImproperlyConfigured
 from django.test import TestCase
@@ -350,3 +351,75 @@
     def test_invalid_url(self):
         self.assertRaises(AttributeError, self.client.get, "/dates/books/2008/oct/01/nopk/")
 
+from views import BookWeekArchive
+
+class WeekArchiveTest(TestCase):
+    """
+    Test that WeekArchive gets the correct queryset for each week in a year. As of 
+    changeset 14656, it does work when the week_format is '%U', i.e., each week begins
+    on a Sunday, which is the default case. However, it did not work correctly when
+    using '%W', i.e., each week begins on a Monday. 
+    
+    This test creates a Book object for each day of a year and then tests that the 
+    correct queryset is returned for all possible cases involving a week.
+    
+    BaseWeekArchiveView.get_dated_items calls a helper function, _date_from_string, 
+    to get the date for a given week number. It does this correctly for weeks 
+    beginning on Sunday, for example, for the 10th week in 2009, with:
+        time.strptime('2009__0__10', '%Y__%w__%U')
+    However, if we are requesting a week beginning on Monday, it should use:
+        time.strptime('2009__1__10', '%Y__%w__%W')
+    but instead it used:
+        time.strptime('2009__0__10', '%Y__%w__%W')
+    """
+    test_year = 2009 # if you use current year, you'll have to deal with allow_future issues
+    
+    def every_day_in_year(self, year=test_year):
+        "Generate a date for every day in a year"
+        date = datetime.date(self.test_year, 1, 1)
+        last_date = date.replace(year=date.year+1)
+        while date < last_date:
+            yield date
+            date += datetime.timedelta(days=1)
+
+    def dates_grouped_by_week(self, week_format):
+        "The dates for an entire year, grouped by week, specified by week_format (%U or %W)"
+        group_key = lambda date:date.strftime(week_format)
+        return itertools.groupby(self.every_day_in_year(), group_key)
+    
+    def setUp(self):
+        "Create a Book for every day of the year"
+        for pubdate in self.every_day_in_year():
+            day_of_year = pubdate.strftime('%j')
+            Book.objects.create(name=day_of_year, slug=day_of_year, pages=1, pubdate=pubdate)
+    
+    def test_simple(self):
+        "See that each Book object exists and is what we expect"
+        for date in self.every_day_in_year():
+            obj = Book.objects.get(pubdate=date)
+            self.assertEqual(obj.name, obj.slug)
+            self.assertEqual(obj.slug, date.strftime('%j'))
+    
+    def test_week_start_Sunday(self):
+        week_format = '%U'
+        self.common_week_start(week_format)
+    
+    def test_week_start_Monday(self):
+        week_format = '%W'
+        self.common_week_start(week_format)
+
+    def common_week_start(self, week_format):
+        """
+        We get a list of dates belonging to each week of the year,
+        as determined by the week_format (either dates starting on Sunday,
+        or dates starting on Monday). Because we have a Book for each day
+        of the year, the list of dates should match the dates from the Books
+        retrieved for that week. 
+        """
+        for key,group in self.dates_grouped_by_week(week_format):
+            dates_in_week = list(group)
+            view_obj = BookWeekArchive(week_format = week_format, year = str(self.test_year), week = key)
+            date_list, qs, extra_context = view_obj.get_dated_items()
+            self.assertEqual(date_list, None)
+            qs_dates = sorted([obj.pubdate for obj in qs])
+            self.assertEqual( dates_in_week, qs_dates )
Index: tests/regressiontests/generic_views/tests.py
===================================================================
--- tests/regressiontests/generic_views/tests.py	(revision 14678)
+++ tests/regressiontests/generic_views/tests.py	(working copy)
@@ -2,4 +2,5 @@
 from regressiontests.generic_views.dates import ArchiveIndexViewTests, YearArchiveViewTests, MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, DateDetailViewTests
 from regressiontests.generic_views.detail import DetailViewTest
 from regressiontests.generic_views.edit import CreateViewTests, UpdateViewTests, DeleteViewTests
-from regressiontests.generic_views.list import ListViewTests
\ No newline at end of file
+from regressiontests.generic_views.list import ListViewTests
+from regressiontests.generic_views.dates import WeekArchiveTest
\ No newline at end of file
