Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptest for the width and height attributes inside the image in the output #601
Conversation
takluyver
added this to the 5.3 milestone
Jun 2, 2017
Carreau
merged commit 2fa33b9
into
jupyter:master
Jun 2, 2017
1 check passed
continuous-integration/travis-ci/pr
The Travis CI build passed
Details
added a commit
to mscuthbert/nbconvert
that referenced
this pull request
Jun 5, 2017
mpacer
added
unlogged
and removed
unlogged
labels
Aug 31, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
mpacer commentedJun 1, 2017
This is in part a test improvement and in part meant to be an exposition on how to modify the tests in relation to #589 for @mscuthbert.
So, you want to check the content of the output, specifically we want to check whether there is a image element that has width and height attributes set. The
'<img
part is going to pick up the imagesrc="[^"]*?"
handles the base64 encoded data uri and([^>]*?)>'
grabs the remainder of the content until the tag is closed (which will include all of the attributes).To run just this test it's easiest to run
py.test nbconvert/exporters/tests/test_html.py
from the top level directory of nbconvert.To be able to inspect the state of the objects in the test, if you inject a python debugging trace (
import pdb; pdb.set_trace()
) that will inject you into a python interpreter at that point in the process and then you can play around with the actual content. So my first step was to insert that before theassert len(output)>0
and then got a handle on the converted content. I then dumped that into https://regex101.com/ (which I find to be a nice interface for testing regular expressions) until I got something that worked to capture the group that I wanted.Then it's a matter of writing the assert statements that directly address what you about, in this case that there are width and height attributes that are present.