hy/tests/importer/test_pyc.py

21 lines
441 B
Python
Raw Normal View History

2013-04-13 18:57:54 +02:00
import os
import imp
import tempfile
from hy.importer import write_hy_as_pyc
def test_pyc():
"""Test pyc compilation."""
f = tempfile.NamedTemporaryFile(suffix='.hy', delete=False)
2013-04-13 21:45:33 +02:00
f.write(b'(defn pyctest [s] s)')
2013-04-13 18:57:54 +02:00
f.close()
write_hy_as_pyc(f.name)
os.unlink(f.name)
cfile = "%s.pyc" % f.name[:-len(".hy")]
mod = imp.load_compiled('pyc', cfile)
os.unlink(cfile)
assert mod.pyctest('Foo') == 'Foo'