提交 90c027cf 编写于 作者: C Carl Meyer

fix logfile with no dirname; fixes #90

上级 1177baf6
News for pip
============
tip
---
* Fixed opening of logfile with no directory name. Thanks Alexandre Conrad.
0.7
---
......
......@@ -188,6 +188,7 @@ def open_logfile(filename, mode='a'):
the file to separate past activity from current activity.
"""
filename = os.path.expanduser(filename)
filename = os.path.abspath(filename)
dirname = os.path.dirname(filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
......
......@@ -4,6 +4,8 @@ import textwrap
from test_pip import here, reset_env, run_pip, clear_environ, write_file
import os
from pip.basecommand import open_logfile
def test_options_from_env_vars():
"""
Test if ConfigOptionParser reads env vars (e.g. not using PyPI here)
......@@ -76,3 +78,13 @@ def test_config_file_override_stack():
assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
def test_log_file_no_directory():
"""
Test opening a log file with no directory name.
"""
fp = open_logfile('testpip.log')
fp.write('can write')
fp.close()
assert os.path.exists(fp.name)
os.remove(fp.name)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册