mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Avoid universal newlines even more
This commit is contained in:
@@ -9,6 +9,7 @@ from __future__ import with_statement
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
from parso import split_lines
|
from parso import split_lines
|
||||||
|
|
||||||
@@ -90,12 +91,14 @@ def _collect_file_tests(code, path, lines_to_execute):
|
|||||||
|
|
||||||
|
|
||||||
def collect_dir_tests(base_dir, test_files):
|
def collect_dir_tests(base_dir, test_files):
|
||||||
|
if sys.version_info[0] == 2:
|
||||||
|
return
|
||||||
for f_name in os.listdir(base_dir):
|
for f_name in os.listdir(base_dir):
|
||||||
files_to_execute = [a for a in test_files.items() if a[0] in f_name]
|
files_to_execute = [a for a in test_files.items() if a[0] in f_name]
|
||||||
lines_to_execute = reduce(lambda x, y: x + y[1], files_to_execute, [])
|
lines_to_execute = reduce(lambda x, y: x + y[1], files_to_execute, [])
|
||||||
if f_name.endswith(".py") and (not test_files or files_to_execute):
|
if f_name.endswith(".py") and (not test_files or files_to_execute):
|
||||||
path = os.path.join(base_dir, f_name)
|
path = os.path.join(base_dir, f_name)
|
||||||
with open(path) as f:
|
with open(path, newline='') as f:
|
||||||
code = f.read()
|
code = f.read()
|
||||||
for case in _collect_file_tests(code, path, lines_to_execute):
|
for case in _collect_file_tests(code, path, lines_to_execute):
|
||||||
yield case
|
yield case
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ def collect_dir_tests(base_dir, test_files, check_thirdparty=False):
|
|||||||
path = os.path.join(base_dir, f_name)
|
path = os.path.join(base_dir, f_name)
|
||||||
|
|
||||||
if is_py3:
|
if is_py3:
|
||||||
with open(path, encoding='utf-8') as f:
|
with open(path, encoding='utf-8', newline='') as f:
|
||||||
source = f.read()
|
source = f.read()
|
||||||
else:
|
else:
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ def test_create_environment_executable():
|
|||||||
assert environment.executable == sys.executable
|
assert environment.executable == sys.executable
|
||||||
|
|
||||||
|
|
||||||
def test_get_default_environment_from_env_does_not_use_safe(tmpdir, monkeypatch):
|
def test_get_default_environment_from_env_does_not_use_safe(tmpdir, monkeypatch, skip_python2):
|
||||||
fake_python = os.path.join(str(tmpdir), 'fake_python')
|
fake_python = os.path.join(str(tmpdir), 'fake_python')
|
||||||
with open(fake_python, 'w') as f:
|
with open(fake_python, 'w', newline='') as f:
|
||||||
f.write('')
|
f.write('')
|
||||||
|
|
||||||
def _get_subprocess(self):
|
def _get_subprocess(self):
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def test_rename_mod(Script, dir_with_content):
|
|||||||
p2 = os.path.join(dir_with_content, 'modr.py')
|
p2 = os.path.join(dir_with_content, 'modr.py')
|
||||||
expected_code = 'import modr\nfoo\n'
|
expected_code = 'import modr\nfoo\n'
|
||||||
assert not os.path.exists(p1)
|
assert not os.path.exists(p1)
|
||||||
with open(p2) as f:
|
with open(p2, newline='') as f:
|
||||||
assert f.read() == expected_code
|
assert f.read() == expected_code
|
||||||
|
|
||||||
assert refactoring.get_renames() == [(p1, p2)]
|
assert refactoring.get_renames() == [(p1, p2)]
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ class Bar:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def pyc_project_path(tmpdir):
|
def pyc_project_path(tmpdir, skip_python2):
|
||||||
path = tmpdir.strpath
|
path = tmpdir.strpath
|
||||||
dummy_package_path = os.path.join(path, "dummy_package")
|
dummy_package_path = os.path.join(path, "dummy_package")
|
||||||
os.mkdir(dummy_package_path)
|
os.mkdir(dummy_package_path)
|
||||||
with open(os.path.join(dummy_package_path, "__init__.py"), 'w'):
|
with open(os.path.join(dummy_package_path, "__init__.py"), 'w', newline=''):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
dummy_path = os.path.join(dummy_package_path, 'dummy.py')
|
dummy_path = os.path.join(dummy_package_path, 'dummy.py')
|
||||||
with open(dummy_path, 'w') as f:
|
with open(dummy_path, 'w', newline='') as f:
|
||||||
f.write(SRC)
|
f.write(SRC)
|
||||||
import compileall
|
import compileall
|
||||||
compileall.compile_file(dummy_path)
|
compileall.compile_file(dummy_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user