Skip to content

Commit

Permalink
Use context manager for open()
Browse files Browse the repository at this point in the history
  • Loading branch information
mcepl committed Apr 27, 2020
1 parent 0385adb commit b4c49e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions rope/base/libutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def path_to_resource(project, path, type=None):
def path_relative_to_project_root(project, path):
return relative(project.address, path)


@utils.deprecated()
def relative(root, path):
root = rope.base.project._realpath(root).replace(os.path.sep, '/')
Expand Down
6 changes: 3 additions & 3 deletions ropetest/advanced_oi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ def test_call_function_and_parameters(self):
def test_report_change_in_libutils(self):
self.project.prefs['automatic_soa'] = True
code = 'class C(object):\n pass\ndef f(p):\n pass\nf(C())\n'
mod_file = open(self.mod.real_path, 'w')
mod_file.write(code)
mod_file.close()
with open(self.mod.real_path, 'w') as mod_file:
mod_file.write(code)

rope.base.libutils.report_change(self.project, self.mod.real_path, '')
pymod = self.project.get_pymodule(self.mod)
c_class = pymod['C'].get_object()
Expand Down

0 comments on commit b4c49e5

Please sign in to comment.