Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test that sometimes leaves files behind in the current working directory #604

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# **Upcoming release**

- #604 Fix test that sometimes leaves files behind in the current working directory (@lieryan)

# Release 1.6.0

Expand Down
26 changes: 14 additions & 12 deletions ropetest/projecttest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os.path
import pathlib
import tempfile
import unittest
from textwrap import dedent
Expand Down Expand Up @@ -67,22 +68,23 @@ def test_creating_files_that_already_exist(self):
self.project.root.create_file(self.sample_file)

def test_making_root_folder_if_it_does_not_exist(self):
project = Project("sampleproject2")
try:
self.assertTrue(
os.path.exists("sampleproject2") and os.path.isdir("sampleproject2")
)
finally:
testutils.remove_project(project)
with tempfile.TemporaryDirectory(dir=testutils.RUN_TMP_DIR) as tmpdir:
project_root = pathlib.Path(tmpdir) / "sampleproject2"
assert not project_root.exists()

project = Project(project_root)

assert project_root.exists()
assert project_root.is_dir()

def test_failure_when_project_root_exists_and_is_a_file(self):
project_root = "sampleproject2"
try:
open(project_root, "w").close()
with tempfile.TemporaryDirectory(dir=testutils.RUN_TMP_DIR) as tmpdir:
project_root = pathlib.Path(tmpdir) / "sampleproject2"
project_root.touch()
assert project_root.exists() and project_root.is_file()

with self.assertRaises(RopeError):
Project(project_root)
finally:
testutils.remove_recursively(project_root)

def test_creating_folders(self):
folderName = "SampleFolder"
Expand Down