Added Media.__repr__().

It makes it easier to debug MediaOrderConflictWarnings
(refs #28377).
This commit is contained in:
Collin Anderson 2017-08-26 10:32:32 -04:00 committed by Tim Graham
parent 8275662a24
commit 751f7a6d9b
2 changed files with 8 additions and 0 deletions

View File

@ -52,6 +52,9 @@ class Media:
self._css = css self._css = css
self._js = js self._js = js
def __repr__(self):
return 'Media(css=%r, js=%r)' % (self._css, self._js)
def __str__(self): def __str__(self):
return self.render() return self.render()

View File

@ -25,6 +25,11 @@ class FormsMediaTestCase(SimpleTestCase):
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""" <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>"""
) )
self.assertEqual(
repr(m),
"Media(css={'all': ('path/to/css1', '/path/to/css2')}, "
"js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3'))"
)
class Foo: class Foo:
css = { css = {