Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
67b957c
Prefix exception names in projecttest.py
lieryan Nov 10, 2026
00d3c69
Move test_non_existent_module to projecttest.py
lieryan Nov 10, 2026
0a8a774
Move test_getting_not_existing_project_file() to ProjectGetModuleReso…
lieryan Nov 10, 2026
b1764ea
Convert ProjectGetModuleResourceTest into pytest-based TestProjectGet…
lieryan Nov 10, 2026
c6b1e59
Add test coverages for getting non-existent resources/modules
lieryan Nov 10, 2026
7d70bb1
Fix non-standard test name
lieryan Nov 10, 2026
2dc46ac
Add basic tests for Project.get_resource()
lieryan Nov 10, 2026
9df71dd
Add more tests defining `Project.get_resource()` behavior
lieryan Nov 10, 2026
5379a21
Split TestProjectGetResource and TestProjectGetModule
lieryan Nov 10, 2026
837ff75
Remove unused no_project in ProjectTest
lieryan Nov 10, 2026
ee1abce
Update ProjectTest to pytest-style TestCase
lieryan Nov 10, 2026
2b31cea
Change default project fixture to not create .ropefolder
lieryan Nov 10, 2026
b6e581e
Move test_simple_path_to_resource to TestProjectGetResource
lieryan Nov 10, 2026
6a5fa5e
Split ProjectTest into logical chunks
lieryan Nov 10, 2026
85d2d54
Skip os.mkfifo test on Windows
lieryan Nov 10, 2026
1888c44
Expanded the test_simple_path_to_resource() to a test class
lieryan Nov 13, 2026
1adc74f
Add libutils.path_to_resource test for getting out-of-project file
lieryan Nov 13, 2026
d45bd1e
Discard drive name when converting resource name to resource path
lieryan Nov 13, 2026
81e3b29
Normalise path separator before interpreting them.
lieryan Nov 13, 2026
d975ee3
Fix tests on Windows
lieryan Nov 11, 2026
ffd4aa5
Update CHANGELOG.md
lieryan Nov 10, 2026
d10c0f9
Clarify changes in resource path handling for Windows
lieryan Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- #119, #928 Fix IndexError in rename and find occurrences when a `from` import is the last thing in a module without a trailing newline (@mcepl)
- #921 Patch the else suite of try statements that also have a finally (@marlon-costa-dc)
- #937 Preserve non-ASCII argument expressions and default values when changing function signatures (@Jinyong-Li)
- #950 On Windows, resource paths are now always interpreted to be relative to project directory, even if they start with a drive name or a path separator, matching the behavior in POSIX/Linux/MacOS (@lieryan)

# Release 1.15.1

Expand Down
10 changes: 6 additions & 4 deletions rope/base/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def get_resource(self, resource_name: str) -> Resource:
path = self._get_resource_path(resource_name)
if not os.path.exists(path):
raise exceptions.ResourceNotFoundError(
"Resource <%s> does not exist" % resource_name
f"Resource <{resource_name}> does not exist"
)
elif os.path.isfile(path):
return File(self, resource_name)
elif os.path.isdir(path):
return Folder(self, resource_name)
else:
raise exceptions.ResourceNotFoundError("Unknown resource " + resource_name)
raise exceptions.ResourceNotFoundError(f"Unknown resource {resource_name}")

def get_python_path_folders(self) -> list[Folder]:
result = []
Expand Down Expand Up @@ -132,7 +132,7 @@ def get_relative_module(
) -> pyobjectsdef.PyPackage | pyobjectsdef.PyModule:
module = self.find_relative_module(name, folder, level)
if module is None:
raise ModuleNotFoundError("Module %s not found" % name)
raise ModuleNotFoundError(f"Module {name} not found")
return self.pycore.resource_to_pyobject(module)

def find_relative_module(
Expand Down Expand Up @@ -284,7 +284,7 @@ def get_module(
return pymod
module = self.find_module(name, folder)
if module is None:
raise ModuleNotFoundError("Module %s not found" % name)
raise ModuleNotFoundError(f"Module {name} not found")
return self.pycore.resource_to_pyobject(module)

def get_files(self) -> list[Resource]:
Expand All @@ -299,6 +299,8 @@ def get_python_files(self) -> list[Resource]:
]

def _get_resource_path(self, name: str) -> str:
_, name = os.path.splitdrive(name)
name = name.replace(os.path.sep, "/").lstrip("/")
return os.path.join(self._address, *name.split("/"))

def _init_ropefolder(self):
Expand Down
7 changes: 7 additions & 0 deletions ropetest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

import rope.base.project
from rope.base import resources
from ropetest import testutils

Expand Down Expand Up @@ -47,10 +48,16 @@ def session_venv_python_executable(session_venv):
yield python_executable


@pytest.fixture
def no_project():
return rope.base.project.get_no_project()


@pytest.fixture
def project(session_venv, session_venv_site_packages):
project = testutils.sample_project(
python_path=[str(session_venv_site_packages)],
ropefolder=None,
)
yield project
testutils.remove_project(project)
Expand Down
9 changes: 9 additions & 0 deletions ropetest/contrib/autoimport/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
from ropetest import testutils


@pytest.fixture
def project(session_venv, session_venv_site_packages):
project = testutils.sample_project(
python_path=[str(session_venv_site_packages)],
)
yield project
testutils.remove_project(project)


@pytest.fixture
def mod1(project):
mod1 = testutils.create_module(project, "mod1")
Expand Down
Loading
Loading