diff --git a/ropetest/conftest.py b/ropetest/conftest.py index d2efc68c6..1b6d1bb77 100644 --- a/ropetest/conftest.py +++ b/ropetest/conftest.py @@ -13,6 +13,13 @@ def project(): testutils.remove_project(project) +@pytest.fixture +def project2(): + project = testutils.sample_project("another_project") + yield project + testutils.remove_project(project) + + @pytest.fixture def project_path(project): yield pathlib.Path(project.address) diff --git a/ropetest/contrib/autoimport/autoimporttest.py b/ropetest/contrib/autoimport/autoimporttest.py index de05672c0..669106188 100644 --- a/ropetest/contrib/autoimport/autoimporttest.py +++ b/ropetest/contrib/autoimport/autoimporttest.py @@ -1,3 +1,5 @@ +import sqlite3 + from contextlib import closing, contextmanager from textwrap import dedent from unittest.mock import ANY, patch @@ -26,15 +28,18 @@ def database_list(connection): return list(connection.execute("PRAGMA database_list")) -def test_in_memory_database_share_cache(project): +def test_in_memory_database_share_cache(project, project2): ai1 = AutoImport(project, memory=True) ai2 = AutoImport(project, memory=True) + ai3 = AutoImport(project2, memory=True) + with ai1.connection: ai1.connection.execute("CREATE TABLE shared(data)") ai1.connection.execute("INSERT INTO shared VALUES(28)") - res = ai2.connection.execute("SELECT data FROM shared") - assert res.fetchone() == (28,) + assert ai2.connection.execute("SELECT data FROM shared").fetchone() == (28,) + with pytest.raises(sqlite3.OperationalError, match="no such table: shared"): + ai3.connection.execute("SELECT data FROM shared").fetchone() def test_autoimport_connection_parameter_with_in_memory(