922_py_compile.py 512 B

1234567891011121314151617181920212223242526272829
  1. print('sandbox mode, module is disabled')
  2. exit()
  3. try:
  4. import os
  5. except ImportError:
  6. print('os is not enabled, skipping test...')
  7. exit(0)
  8. import sys
  9. if sys.platform == 'win32':
  10. exe_name = 'main.exe'
  11. else:
  12. exe_name = './main'
  13. assert os.system(f'{exe_name} --compile python/heapq.py heapq1.pyc') == 0
  14. assert os.path.exists('heapq1.pyc')
  15. import heapq1
  16. import heapq
  17. a = [1, 2, -3, 2, 1, 5, 11, 123] * 10
  18. b = a.copy()
  19. heapq.heapify(a)
  20. heapq1.heapify(b)
  21. assert a == b
  22. os.remove('heapq1.pyc')