Fantomas42/django-blog-zinnia — pull request #281 by marky1991 (2013-09-25 05:29:44+00:00)
Title: Made it django 1.6 and Python 3 compatible

With this patch, the app's tests all pass in django 1.6 and python 3.3. The only remaining failures are query-counting related tests (which I believe are a result of django-tagging being weird. See https://groups.google.com/forum/#!topic/django-blog-zinnia/LRUzSxLlHTM ), two tagging-related tests (I believe this is django-tagging's fault), and tests that import custom_url_shortener.py and custom_spam_checker.py . (Both of which do nothing but raise exceptions, guaranteeing the tests will fail.) The remaining failures fail when using the most recent version of 1.5, under python 2, and using the your most recent version of django-blog-zinnia, so they are not new regressions. I think they could most easily be fixed by replacing django-tagging with a better-supported tagging app. I'd like to address that and the related failures with a later patch.

Some key changes:
-Changes to how views/mixins/archives.py 's get_previous_next_published works.
-Replacement of explicit __unicode__ calls with six.text_type calls.
-Changed how pearson_score works completely to match the algorithm found on the internet. The original version returned values that disagreed with wolfram's calculator. My updated version matches the online calculator's values.
-in preview.py, we now return str(self.preview) instead of the soup itself. (Returning a non-string in __str__ in python 3 raises an exception)
-assert(Not)Equals calls converted to assert(Not)Equal to silence deprecation warnings
-a new urlEqual function was added in tests/utils.py . This is intended to compare urls that have querystrings, where ordering doesn't matter. (So two urls with querystrings in different order should still compare equal)

Some remaining questions:
-CategoryAdminForm in admin/forms.py may or may not be right. The code used originally is not a part of the API so it's not documented at all. (It's not even documented in the source...) The solution currently provided makes the code run and appears to work. (It's the best guess of me and some people on the django-users IRC channel)
-Why does the pearson_score function in comparison.py return 1-r instead of just r? (See the code for context)
-test_vector_builder in tests/comparison.py badly needs to be looked at. I've made it disregard ordering now. I'm not sure if this is desired or not. Right now, the code assumes a stable iteration order over dictionary keys, which is not a valid assumption. I've done my best to fix it, but I don't really know if it matches what you intended or not. If the function wants to preserve order, it needs to be completely rewritten.
-The changes to xmlrpc with respect to bytes vs. strings needs to be looked at. I think I did it correctly, but I'm not 100% sure. (Also tests/utils.py, TestTransport)