Brian Kearns avatar Brian Kearns committed 57305c3

don't try to find stdlib if we didn't find an executable, test

Comments (0)

Files changed (2)

pypy/module/sys/initpath.py

     stdlib.
     If it cannot be found, return (None, None).
     """
+    if executable == '':
+        return None, None
     search = executable
     while True:
         dirname = resolvedirof(search)

pypy/module/sys/test/test_initpath.py

     b = prefix.join('lib-python', dirname).ensure(dir=1)
     return a, b
 
-def test_find_stdlib(tmpdir):
+def test_find_stdlib(tmpdir, monkeypatch):
     bin_dir = tmpdir.join('bin').ensure(dir=True)
     pypy = bin_dir.join('pypy').ensure(file=True)
     build_hierarchy(tmpdir)
     path, prefix = find_stdlib(None, str(pypy))
     assert prefix == tmpdir
+    # shouldn't find stdlib if executable == '' even if parent dir has a stdlib
+    monkeypatch.chdir(tmpdir.join('bin'))
+    assert find_stdlib(None, '') == (None, None)
 
 @py.test.mark.skipif('not hasattr(os, "symlink")')
 def test_find_stdlib_follow_symlink(tmpdir):
     assert find_executable('pypy') == a.join('pypy.exe')
 
 def test_resolvedirof(tmpdir):
+    assert resolvedirof('') == os.path.abspath(os.path.join(os.getcwd(), '..'))
     foo = tmpdir.join('foo').ensure(dir=True)
     bar = tmpdir.join('bar').ensure(dir=True)
     myfile = foo.join('myfile').ensure(file=True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.