PageRenderTime 50ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/module/pyexpat/test/test_build.py

https://bitbucket.org/pypy/pypy/
Python | 35 lines | 30 code | 5 blank | 0 comment | 4 complexity | 97fa02f1e399a5df434d124a6ca4ee9c MD5 | raw file
Possible License(s): AGPL-3.0, BSD-3-Clause, Apache-2.0
  1. from rpython.translator.translator import TranslationContext
  2. from rpython.translator.c.genc import CStandaloneBuilder
  3. from rpython.annotator.listdef import s_list_of_strings
  4. from rpython.rtyper.lltypesystem import rffi, lltype
  5. from rpython.rtyper.tool.rffi_platform import CompilationError
  6. import os
  7. import py
  8. try:
  9. import pyexpat
  10. except ImportError:
  11. py.test.skip("No module expat")
  12. try:
  13. from pypy.module.pyexpat import interp_pyexpat
  14. except (ImportError, CompilationError):
  15. py.test.skip("Expat not installed")
  16. def test_build():
  17. def entry_point(argv):
  18. parser = interp_pyexpat.XML_ParserCreate("test")
  19. interp_pyexpat.XML_ParserFree(parser)
  20. res = interp_pyexpat.XML_ErrorString(3)
  21. os.write(1, rffi.charp2str(res))
  22. return 0
  23. t = TranslationContext()
  24. t.buildannotator().build_types(entry_point, [s_list_of_strings])
  25. t.buildrtyper().specialize()
  26. builder = CStandaloneBuilder(t, entry_point, t.config)
  27. builder.generate_source()
  28. builder.compile()
  29. data = builder.cmdexec()
  30. assert data == pyexpat.ErrorString(3)