Commit c5ae5e82 authored by Romain Casati's avatar Romain Casati
Browse files

Testing hacked modules.

parent a2ca8358
<svg width="100%" height="100%" preserveaspectratio="xMidYMid slice" viewbox="0 0 640 480"><animate id="af_0" attributename="opacity" attributetype="CSS" from="1" to="1" begin="0s" dur="1ms" fill="freeze"></animate><g transform="translate(320 240)"></g><g transform="translate(320 240)"><line x1="0" y1="0" x2="0" y2="0" style="stroke: black;stroke-width: 1"><animate id="af_2" attributename="x2" attributetype="XML" from="0" to="0" dur="1ms" fill="freeze" begin="af_1.end"></animate><animate attributename="y2" attributetype="XML" begin="af_1.end" from="0" to="0" dur="1ms" fill="freeze"></animate></line><line x1="0" y1="0" x2="0" y2="0" style="stroke: black;stroke-width: 1"><animate id="af_5" attributename="x2" attributetype="XML" from="0" to="100" dur=" 0.535s" fill="freeze" begin="af_4.end"></animate><animate attributename="y2" attributetype="XML" begin="af_4.end" from="0" to="0" dur=" 0.535s" fill="freeze"></animate></line></g><g transform="translate(320 240)"></g><g transform="translate(320 240)"><polygon points="0,16 ,-2,14 ,-1,10 ,-4,7 ,-7,9 ,-9,8 ,-6,5 ,-7,1 ,-5,-3 ,-8,-6 ,-6,-8 ,-4,-5 ,0,-7 ,4,-5 ,6,-8 ,8,-6 ,5,-3 ,7,1 ,6,5 ,9,8 ,7,9 ,4,7 ,1,10 ,2,14 " stroke="black" fill="black" stroke-width="1" opacity="0"><animate id="af_1" begin="af_0.end" dur="1ms" fill="freeze" attributename="opacity" attributetype="XML" from="0" to="1"></animate><animateMotion begin="af_2.end" dur="1ms" fill="remove"></animateMotion><animateTransform attributename="transform" id="af_3" type="rotate" from="0,0,0" to="0,0,0" begin="af_2.end" dur="1ms" fill="freeze"></animateTransform><animateMotion begin="af_3.end" dur="1ms" fill="remove"></animateMotion><animateTransform attributename="transform" id="af_4" type="rotate" from="-90,0,0" to="-90,0,0" begin="af_3.end" dur="1ms" fill="freeze"></animateTransform><animateMotion begin="af_4.end" dur="1ms" fill="remove"></animateMotion><animateMotion from="0.0,-0.0" to="100.0,-0.0" dur=" 0.535s" begin="af_4.end" fill="freeze"></animateMotion></polygon></g></svg>
\ No newline at end of file
from pathlib import Path
import re
def test_all(selenium):
# ensure all hacked modules are tested
tested = set(g[len('test_'):] for g in globals()
if g.startswith('test_') and g != 'test_all')
result = selenium.run_basthon("""
from basthon import _hack_modules
set(g[len('hack_'):] for g in dir(_hack_modules)
if g.startswith('hack_'))""")['result']
hacked = eval(result['result']['text/plain'])
assert tested == hacked
def test_PIL(selenium):
#assert False
def test_matplotlib(selenium):
#assert False
def test_folium(selenium):
#assert False
def test_pandas(selenium):
#assert False
def test_sympy(selenium):
#assert False
def test_turtle(selenium):
import turtle
""", return_data=False)
# can't access content like this
# elem = result['content']
# because of selenium's StaleElementReferenceException
# bypassing it via JS
svg = selenium.run_js("return window._basthon_eval_data.display.content.outerHTML")
svg = re.sub('\"af_[0-9a-f]+_', '\"af_', svg)
with open(Path(__file__).parent / 'data' / 'turtle.svg') as f:
target =
assert svg == target
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment