test_commands.py 786 B

1234567891011121314151617181920212223
  1. import io
  2. from testpath import assert_isfile
  3. from nsist import commands, _rewrite_shebangs
  4. cmds = {'acommand': {'entry_point': 'somemod:somefunc',
  5. 'extra_preamble': io.StringIO(u'import extra')}}
  6. def test_prepare_bin_dir(tmpdir):
  7. commands.prepare_bin_directory(tmpdir, cmds)
  8. assert_isfile(str(tmpdir / 'acommand.exe'))
  9. script_file = tmpdir / 'acommand-script.py'
  10. assert_isfile(str(script_file))
  11. with script_file.open() as f:
  12. script_contents = f.read()
  13. assert script_contents.startswith("#!python")
  14. assert 'import extra' in script_contents
  15. assert 'somefunc()' in script_contents
  16. _rewrite_shebangs.main(['_rewrite_shebangs.py', str(tmpdir)])
  17. with script_file.open() as f:
  18. assert f.read().startswith('#!"')