improve URLWrapper comparison

* speed up via reduced slugify calls (only call when needed)
* fix __repr__ to not contain str, should call repr on name
* add test_urlwrappers and move URLWrappers tests there
  * add new equality test
* cleanup header

additionally:
* Content is now decorated with python_2_unicode_compatible
  instead of treating __str__ differently
* better formatting for test_article_metadata_key_lowercase
  to actually output the conflict instead of a non descriptive
  error
This commit is contained in:
derwinlu 2015-06-19 11:19:21 +02:00
commit 5389543a39
5 changed files with 80 additions and 48 deletions

View file

@ -25,6 +25,7 @@ from pelican.urlwrappers import (URLWrapper, Author, Category, Tag) # NOQA
logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class Content(object):
"""Represents a content.
@ -148,12 +149,7 @@ class Content(object):
signals.content_object_init.send(self)
def __str__(self):
if self.source_path is None:
return repr(self)
elif six.PY3:
return self.source_path or repr(self)
else:
return str(self.source_path.encode('utf-8', 'replace'))
return self.source_path or repr(self)
def check_properties(self):
"""Test mandatory properties are set."""