mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
20 lines
626 B
Python
20 lines
626 B
Python
import tempfile
|
|
|
|
from galaxy.util.checkers import check_html
|
|
|
|
|
|
def test_check_html():
|
|
html_text = '<p>\n<a href="url">Link</a>\n</p>\n'
|
|
assert check_html(html_text, file_path=False)
|
|
# Test a non-HTML binary string
|
|
assert not check_html(b"No HTML here\nSecond line\n", file_path=False)
|
|
with tempfile.NamedTemporaryFile(mode="w") as tmp:
|
|
tmp.write(html_text)
|
|
tmp.flush()
|
|
assert check_html(tmp.name)
|
|
# Test a non-UTF8 binary file
|
|
with tempfile.NamedTemporaryFile(mode="wb") as tmpb:
|
|
tmpb.write(b"\x1f\x8b")
|
|
tmpb.flush()
|
|
assert not check_html(tmpb.name)
|