1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-15 21:08:55 +00:00

Fix tests creating garbage project in ~/GNS3/project

This commit is contained in:
Julien Duponchelle 2015-02-06 11:14:56 +01:00
parent 8118d7762f
commit 5c3969ae79
2 changed files with 9 additions and 2 deletions

View File

@ -107,7 +107,11 @@ def free_console_port(request, port_manager):
@pytest.yield_fixture(autouse=True) @pytest.yield_fixture(autouse=True)
def run_around_tests(): def run_around_tests(monkeypatch):
"""
This setup a temporay project file environnement around tests
"""
tmppath = tempfile.mkdtemp() tmppath = tempfile.mkdtemp()
config = Config.instance() config = Config.instance()
@ -115,6 +119,8 @@ def run_around_tests():
server_section["project_directory"] = tmppath server_section["project_directory"] = tmppath
config.set_section_config("Server", server_section) config.set_section_config("Server", server_section)
monkeypatch.setattr("gns3server.modules.project.Project._get_default_project_directory", lambda *args: tmppath)
yield yield
# An helper should not raise Exception # An helper should not raise Exception

View File

@ -198,8 +198,9 @@ def test_project_close_temporary_project(loop, manager):
assert os.path.exists(directory) is False assert os.path.exists(directory) is False
def test_get_default_project_directory(): def test_get_default_project_directory(monkeypatch):
monkeypatch.undo()
project = Project() project = Project()
path = os.path.normpath(os.path.expanduser("~/GNS3/projects")) path = os.path.normpath(os.path.expanduser("~/GNS3/projects"))
assert project._get_default_project_directory() == path assert project._get_default_project_directory() == path