From 954c501e576d8bf16dcb9f06c17a8c4b15744d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Mon, 13 Jan 2025 07:16:58 +0100 Subject: [PATCH] fix tests --- conan/api/conan_api.py | 1 - conan/api/subapi/config.py | 2 +- conans/client/migrations.py | 2 +- test/integration/command/config_test.py | 2 -- test/integration/test_migrations.py | 2 +- 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/conan/api/conan_api.py b/conan/api/conan_api.py index cc9b8c84dd4..a3961ec967e 100644 --- a/conan/api/conan_api.py +++ b/conan/api/conan_api.py @@ -61,7 +61,6 @@ def __init__(self, cache_folder=None): def reinit(self): self.config.reinit() - self.config.migrate() self.remotes.reinit() self.local.reinit() diff --git a/conan/api/subapi/config.py b/conan/api/subapi/config.py index e1942c4928d..3c90ced40ef 100644 --- a/conan/api/subapi/config.py +++ b/conan/api/subapi/config.py @@ -12,6 +12,7 @@ from conan.internal.cache.home_paths import HomePaths from conan.internal.conan_app import ConanApp from conan.internal.default_settings import default_settings_yml +from conans.client.migrations import ClientMigrator from conans.client.graph.graph import CONTEXT_HOST, RECIPE_VIRTUAL, Node from conans.client.graph.graph_builder import DepsGraphBuilder from conans.client.graph.profile_node_definer import consumer_definer @@ -195,7 +196,6 @@ def appending_recursive_dict_update(d, u): def migrate(self): # Migration system # TODO: A prettier refactoring of migrators would be nice - from conans.client.migrations import ClientMigrator migrator = ClientMigrator(self.home(), conan_version) migrator.migrate() diff --git a/conans/client/migrations.py b/conans/client/migrations.py index 82997ba4e9e..026ef8b819b 100644 --- a/conans/client/migrations.py +++ b/conans/client/migrations.py @@ -3,7 +3,6 @@ import textwrap from conan.api.output import ConanOutput -from conan.api.subapi.config import ConfigAPI from conan.internal.default_settings import migrate_settings_file from conans.migrations import Migrator from conans.util.dates import timestamp_now @@ -76,6 +75,7 @@ def migrate(home_folder): def _migrate_pkg_db_lru(cache_folder, old_version): + from conan.api.subapi.config import ConfigAPI config = ConfigAPI.load_config(cache_folder) storage = config.get("core.cache:storage_path") or os.path.join(cache_folder, "p") db_filename = os.path.join(storage, 'cache.sqlite3') diff --git a/test/integration/command/config_test.py b/test/integration/command/config_test.py index a742ab06d54..8d480bb996f 100644 --- a/test/integration/command/config_test.py +++ b/test/integration/command/config_test.py @@ -234,10 +234,8 @@ def test_config_reinit(): assert config_api.global_conf.get("core.upload:retry", check_type=int) != 7 conan_api.config.install(global_conf_folder, verify_ssl=False) - # No effect yet, we haven't reinitialized the API after the config installation assert config_api.global_conf.get("core.upload:retry", check_type=int) != 7 conan_api.reinit() - assert config_api.global_conf.get("core.upload:retry", check_type=int) == 7 diff --git a/test/integration/test_migrations.py b/test/integration/test_migrations.py index f8454443150..61020230305 100644 --- a/test/integration/test_migrations.py +++ b/test/integration/test_migrations.py @@ -148,6 +148,6 @@ def test_back_default_compatibility_migration(): # simulate that we are in 2.3.2 and the old one is latest conan_version migrator = ClientMigrator(t.cache_folder, Version("2.3.2")) - with patch('conan.api.conan_api.ClientMigrator', new=lambda *args, **kwargs: migrator): + with patch('conan.api.subapi.config.ClientMigrator', new=lambda *args, **kwargs: migrator): t.run("-v") # Fire the backward migration assert f"WARN: Downgrading cache from Conan {conan_version} to 2.3.2" in t.out