Issue #37 resolved

Two Assertion failures on Windows tests (script_header)

Jason R. Coombs
created an issue

I do regularly run the tests on Windows. Back around 0.6.21 or so, the tests were passing on Windows in totality. When I run the tests now, I get two failures in tests due to shebang lines in scripts (complete transcript):

======================================================================
FAIL: test_get_script_args (setuptools.tests.test_easy_install.TestEasyInstallTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\jaraco\projects\setuptools\setuptools\tests\test_easy_install.py", line 86, in test_get_script_args
    self.assertEqual(script, WANTED)
AssertionError: '#!"C:\\Program Files\\Python33\\python.exe"\n# EASY-INSTALL-ENTRY-SCRIPT: \'spe [truncated]... != "#!C:\\Program Files\\Python33\\python.exe\n# EASY-INSTALL-ENTRY-SCRIPT: 'spec', [truncated]...
- #!"C:\Program Files\Python33\python.exe"
?   -                                    -
+ #!C:\Program Files\Python33\python.exe
  # EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
  __requires__ = 'spec'
  import sys
  from pkg_resources import load_entry_point

  if __name__ == '__main__':
      sys.exit(
          load_entry_point('spec', 'console_scripts', 'name')()
      )


======================================================================
FAIL: test_get_script_header (setuptools.tests.test_resources.ScriptHeaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\jaraco\projects\setuptools\setuptools\tests\test_resources.py", line 508, in test_get_script_header
    '#!%s\n' % os.path.normpath(sys.executable))
AssertionError: '#!"C:\\Program Files\\Python33\\python.exe"\n' != '#!C:\\Program Files\\Python33\\python.exe\n'
- #!"C:\Program Files\Python33\python.exe"
?   -                                    -
+ #!C:\Program Files\Python33\python.exe


----------------------------------------------------------------------

I've been ignoring these test failures because I believe it is the tests that are broken and not the implementation. I suspect these tests will not fail when there is not a space in the path to python.exe.

Comments (4)

  1. Arfrever Frehtes Taifersar Arahesis

    Shebangs do not work at all on Windows, so these tests could be skipped on Windows.

    Quotes in shebang are interpreted as integral part of path (at least on Linux):

    $ cat test1.sh
    #!/bin/bash
    $ cat test2.sh
    #!"/bin/bash"
    $ ./test1.sh
    $ ./test2.sh
    bash: ./test2.sh: "/bin/bash": bad interpreter: No such file or directory
    $
    

    Such quotes should not be added around a path with spaces. Probably tests should be skipped in such situation.

  2. Jason R. Coombs reporter

    I believe that both setuptools and the Windows py launcher both honor the shebang in Python scripts and more importantly do a better job of it than Unix does, supporting valid filenames with spaces in them. Furthermore, I'd like to get these tests passing as they're not only testing the headers.

  3. Log in to comment