##// END OF EJS Templates
Document _repr_mimebundle_...
Matthias Bussonnier -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -960,7 +960,7 b' class MimeBundleFormatter(BaseFormatter):'
960 if method is not None:
960 if method is not None:
961 d = {}
961 d = {}
962 d['include'] = include
962 d['include'] = include
963 d['exclude'] = include
963 d['exclude'] = exclude
964 return method(**d)
964 return method(**d)
965 return None
965 return None
966 else:
966 else:
@@ -116,8 +116,6 b' def test_for_type():'
116 def test_for_type_string():
116 def test_for_type_string():
117 f = PlainTextFormatter()
117 f = PlainTextFormatter()
118
118
119 mod = C.__module__
120
121 type_str = '%s.%s' % (C.__module__, 'C')
119 type_str = '%s.%s' % (C.__module__, 'C')
122
120
123 # initial return, None
121 # initial return, None
@@ -166,7 +164,6 b' def test_lookup_by_type():'
166 f = PlainTextFormatter()
164 f = PlainTextFormatter()
167 f.for_type(C, foo_printer)
165 f.for_type(C, foo_printer)
168 nt.assert_is(f.lookup_by_type(C), foo_printer)
166 nt.assert_is(f.lookup_by_type(C), foo_printer)
169 type_str = '%s.%s' % (C.__module__, 'C')
170 with nt.assert_raises(KeyError):
167 with nt.assert_raises(KeyError):
171 f.lookup_by_type(A)
168 f.lookup_by_type(A)
172
169
@@ -475,6 +472,31 b' def test_repr_mime():'
475 nt.assert_equal(d['image/png'], 'i-overwrite', '_repr_mimebundle_ take precedence')
472 nt.assert_equal(d['image/png'], 'i-overwrite', '_repr_mimebundle_ take precedence')
476
473
477
474
475
476 def test_pass_correct_include_exclude():
477 class Tester(object):
478
479 def __init__(self, include=None, exclude=None):
480 self.include = include
481 self.exclude = exclude
482
483 def _repr_mimebundle_(self, include, exclude, **kwargs):
484 if include and (include != self.include):
485 raise ValueError('include got modified: display() may be broken.')
486 if exclude and (exclude != self.exclude):
487 raise ValueError('exclude got modified: display() may be broken.')
488
489 return None
490
491 include = {'a', 'b', 'c'}
492 exclude = {'c', 'e' , 'f'}
493
494 f = get_ipython().display_formatter
495 f.format(Tester(include=include, exclude=exclude), include=include, exclude=exclude)
496 f.format(Tester(exclude=exclude), exclude=exclude)
497 f.format(Tester(include=include), include=include)
498
499
478 def test_repr_mime_meta():
500 def test_repr_mime_meta():
479 class HasReprMimeMeta(object):
501 class HasReprMimeMeta(object):
480 def _repr_mimebundle_(self, include=None, exclude=None):
502 def _repr_mimebundle_(self, include=None, exclude=None):
@@ -499,5 +521,3 b' def test_repr_mime_meta():'
499 'height': 10,
521 'height': 10,
500 }
522 }
501 })
523 })
502
503
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now