##// END OF EJS Templates
outputarea.js: Wrap inline SVGs inside an iframe...
outputarea.js: Wrap inline SVGs inside an iframe When multiple inline SVGs are included in a single document, they share the same parse tree. Therefore, style collisions and use id collisions can occur and upset the rendering. This patch wraps each SVG inside an individual iframe, ensuring that SVG's declarations do not collide. (The SVG representation is kept as XML and not converted to a binary format, so I do not think this approach precludes the use of d3.js) Tested on: * Chrome Version 29.0.1547.57 Debian 7.1 (217859) * Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130806 Firefox/17.0 Iceweasel/17.0.8 Closes #1866

File last commit:

r13180:deb0ad90
r13408:333abbe5
Show More
launchnotebook.py
87 lines | 2.5 KiB | text/x-python | PythonLexer
"""Base class for notebook tests."""
import os
import sys
import time
import requests
from contextlib import contextmanager
from subprocess import Popen, PIPE
from unittest import TestCase
from IPython.utils.tempdir import TemporaryDirectory
class NotebookTestBase(TestCase):
"""A base class for tests that need a running notebook.
This creates an empty profile in a temp ipython_dir
and then starts the notebook server with a separate temp notebook_dir.
"""
port = 12341
@classmethod
def wait_until_alive(cls):
"""Wait for the server to be alive"""
url = 'http://localhost:%i/api/notebooks' % cls.port
while True:
try:
requests.get(url)
except requests.exceptions.ConnectionError:
time.sleep(.1)
else:
break
@classmethod
def wait_until_dead(cls):
"""Wait for the server to stop getting requests after shutdown"""
url = 'http://localhost:%i/api/notebooks' % cls.port
while True:
try:
requests.get(url)
except requests.exceptions.ConnectionError:
break
else:
time.sleep(.1)
@classmethod
def setup_class(cls):
cls.ipython_dir = TemporaryDirectory()
cls.notebook_dir = TemporaryDirectory()
notebook_args = [
sys.executable, '-c',
'from IPython.html.notebookapp import launch_new_instance; launch_new_instance()',
'--port=%d' % cls.port,
'--no-browser',
'--ipython-dir=%s' % cls.ipython_dir.name,
'--notebook-dir=%s' % cls.notebook_dir.name,
]
devnull = open(os.devnull, 'w')
cls.notebook = Popen(notebook_args,
stdout=devnull,
stderr=devnull,
)
cls.wait_until_alive()
@classmethod
def teardown_class(cls):
cls.notebook.terminate()
cls.ipython_dir.cleanup()
cls.notebook_dir.cleanup()
cls.wait_until_dead()
@classmethod
def base_url(cls):
return 'http://localhost:%i/' % cls.port
@contextmanager
def assert_http_error(status, msg=None):
try:
yield
except requests.HTTPError as e:
real_status = e.response.status_code
assert real_status == status, \
"Expected status %d, got %d" % (real_status, status)
if msg:
assert msg in str(e), e
else:
assert False, "Expected HTTP error status"