mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Fix issue where file is detected as library code when it shouldn't. Fixes #457
This commit is contained in:
parent
7aa6f4c83a
commit
75bb3a751d
2 changed files with 36 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ from _pydev_imps._pydev_saved_modules import threading
|
|||
from pydevd_file_utils import normcase
|
||||
from _pydevd_bundle.pydevd_constants import USER_CODE_BASENAMES_STARTING_WITH, \
|
||||
LIBRARY_CODE_BASENAMES_STARTING_WITH, IS_PYPY
|
||||
from _pydevd_bundle import pydevd_constants
|
||||
|
||||
try:
|
||||
xrange # noqa
|
||||
|
|
@ -209,7 +210,11 @@ class FilesFiltering(object):
|
|||
roots = _convert_to_str_and_clear_empty(roots)
|
||||
new_roots = []
|
||||
for root in roots:
|
||||
new_roots.append(self._absolute_normalized_path(root))
|
||||
path = self._absolute_normalized_path(root)
|
||||
if pydevd_constants.IS_WINDOWS:
|
||||
new_roots.append(path + '\\')
|
||||
else:
|
||||
new_roots.append(path + '/')
|
||||
return new_roots
|
||||
|
||||
def _absolute_normalized_path(self, filename):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,36 @@
|
|||
from _pydevd_bundle.pydevd_constants import IS_WINDOWS
|
||||
|
||||
|
||||
def test_in_project_roots_prefix_01(tmpdir):
|
||||
from _pydevd_bundle.pydevd_filtering import FilesFiltering
|
||||
files_filtering = FilesFiltering()
|
||||
|
||||
another = str(tmpdir.join('another'))
|
||||
assert not another.endswith('/') and not another.endswith('\\')
|
||||
|
||||
files_filtering.set_library_roots([another])
|
||||
files_filtering.set_project_roots([])
|
||||
assert not files_filtering.in_project_roots(another + '/f.py')
|
||||
assert not files_filtering.in_project_roots(another + '\\f.py')
|
||||
|
||||
assert files_filtering.in_project_roots(another + 'f.py')
|
||||
|
||||
|
||||
def test_in_project_roots_prefix_02(tmpdir):
|
||||
from _pydevd_bundle.pydevd_filtering import FilesFiltering
|
||||
files_filtering = FilesFiltering()
|
||||
|
||||
another = str(tmpdir.join('another'))
|
||||
assert not another.endswith('/') and not another.endswith('\\')
|
||||
|
||||
files_filtering.set_library_roots([])
|
||||
files_filtering.set_project_roots([another])
|
||||
assert files_filtering.in_project_roots(another + '/f.py')
|
||||
assert files_filtering.in_project_roots(another + '\\f.py')
|
||||
|
||||
assert not files_filtering.in_project_roots(another + 'f.py')
|
||||
|
||||
|
||||
def test_in_project_roots(tmpdir):
|
||||
from _pydevd_bundle.pydevd_filtering import FilesFiltering
|
||||
files_filtering = FilesFiltering()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue