test_installerbuilder.py 1009 B

12345678910111213141516171819202122232425262728293031
  1. import io
  2. from os.path import join as pjoin
  3. from nsist import InstallerBuilder, DEFAULT_ICON
  4. from .utils import assert_is_file, test_dir
  5. sample_preamble = pjoin(test_dir, u'sample_preamble.py')
  6. def test_prepare_shortcuts(tmpdir):
  7. shortcuts = {'sc1': {'entry_point': 'norwegian.blue:parrot',
  8. 'icon': DEFAULT_ICON,
  9. 'console': False,
  10. 'extra_preamble': sample_preamble}}
  11. ib = InstallerBuilder("Test App", "1.0", shortcuts, build_dir=tmpdir)
  12. ib.prepare_shortcuts()
  13. scfile = pjoin(tmpdir, 'sc1.launch.pyw')
  14. assert_is_file(scfile)
  15. with io.open(scfile, 'r', encoding='utf-8') as f:
  16. contents = f.read()
  17. last2lines = [l.strip() for l in contents.rstrip().splitlines()[-2:]]
  18. assert last2lines == ['from norwegian.blue import parrot', 'parrot()']
  19. with io.open(sample_preamble, 'r', encoding='utf-8') as f:
  20. preamble_contents = f.read().strip()
  21. assert preamble_contents in contents