conftest.py 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import pytest
  12. from taipy.common.config import Config
  13. from taipy.common.config.section import Section
  14. from tests.common.config.utils.section_for_tests import SectionForTest
  15. from tests.common.config.utils.unique_section_for_tests import UniqueSectionForTest
  16. @pytest.fixture(scope="function", autouse=True)
  17. def reset(reset_configuration_singleton):
  18. reset_configuration_singleton()
  19. register_test_sections()
  20. def register_test_sections():
  21. Config._register_default(UniqueSectionForTest("default_attribute"))
  22. Config.configure_unique_section_for_tests = UniqueSectionForTest._configure
  23. Config.unique_section_name = Config.unique_sections[UniqueSectionForTest.name]
  24. Config._register_default(SectionForTest(Section._DEFAULT_KEY, "default_attribute", prop="default_prop", prop_int=0))
  25. Config.configure_section_for_tests = SectionForTest._configure
  26. Config.section_name = Config.sections[SectionForTest.name]