test_installerbuilder.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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. tmpdir = str(tmpdir)
  8. shortcuts = {'sc1': {'entry_point': 'norwegian.blue:parrot',
  9. 'icon': DEFAULT_ICON,
  10. 'console': False,
  11. 'extra_preamble': sample_preamble}}
  12. ib = InstallerBuilder("Test App", "1.0", shortcuts, build_dir=tmpdir)
  13. ib.prepare_shortcuts()
  14. scfile = pjoin(tmpdir, 'sc1.launch.pyw')
  15. assert_is_file(scfile)
  16. with io.open(scfile, 'r', encoding='utf-8') as f:
  17. contents = f.read()
  18. last2lines = [l.strip() for l in contents.rstrip().splitlines()[-2:]]
  19. assert last2lines == ['from norwegian.blue import parrot', 'parrot()']
  20. with io.open(sample_preamble, 'r', encoding='utf-8') as f:
  21. preamble_contents = f.read().strip()
  22. assert preamble_contents in contents