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

/pypy/config/test/test_pypyoption.py

https://bitbucket.org/pypy/pypy/
Python | 60 lines | 50 code | 10 blank | 0 comment | 3 complexity | f8bf686cc1c0156af67b854ce6616a37 MD5 | raw file
Possible License(s): AGPL-3.0, BSD-3-Clause, Apache-2.0
  1. import py
  2. from pypy.config.pypyoption import get_pypy_config, set_pypy_opt_level
  3. from rpython.config.config import Config, ConfigError
  4. from rpython.config.translationoption import set_opt_level
  5. thisdir = py.path.local(__file__).dirpath()
  6. def test_required():
  7. conf = get_pypy_config()
  8. assert not conf.translating
  9. assert conf.objspace.usemodules.gc
  10. def test_conflicting_gcrootfinder():
  11. conf = get_pypy_config()
  12. conf.translation.gc = "boehm"
  13. py.test.raises(ConfigError, "conf.translation.gcrootfinder = 'asmgcc'")
  14. def test_frameworkgc():
  15. for name in ["minimark", "semispace"]:
  16. conf = get_pypy_config()
  17. assert conf.translation.gctransformer != "framework"
  18. conf.translation.gc = name
  19. assert conf.translation.gctransformer == "framework"
  20. def test_set_opt_level():
  21. conf = get_pypy_config()
  22. set_opt_level(conf, '0')
  23. assert conf.translation.gc == 'boehm'
  24. assert conf.translation.backendopt.none == True
  25. conf = get_pypy_config()
  26. set_opt_level(conf, '2')
  27. assert conf.translation.gc != 'boehm'
  28. assert not conf.translation.backendopt.none
  29. conf = get_pypy_config()
  30. set_opt_level(conf, 'mem')
  31. assert conf.translation.gcremovetypeptr
  32. assert not conf.translation.backendopt.none
  33. def test_set_pypy_opt_level():
  34. conf = get_pypy_config()
  35. set_pypy_opt_level(conf, '2')
  36. assert conf.objspace.std.intshortcut
  37. conf = get_pypy_config()
  38. set_pypy_opt_level(conf, '0')
  39. assert not conf.objspace.std.intshortcut
  40. def test_check_documentation():
  41. def check_file_exists(fn):
  42. assert configdocdir.join(fn).check()
  43. from pypy.doc.config.generate import all_optiondescrs
  44. configdocdir = thisdir.dirpath().dirpath().join("doc", "config")
  45. for descr in all_optiondescrs:
  46. prefix = descr._name
  47. c = Config(descr)
  48. for path in c.getpaths(include_groups=True):
  49. fn = prefix + "." + path + ".txt"
  50. yield fn, check_file_exists, fn