1
0

test_installerbuilder.py 1.0 KB

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