Skip to content

Refactor integration tests #328

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

Open
folmos-at-orange opened this issue Jan 15, 2025 · 0 comments
Open

Refactor integration tests #328

folmos-at-orange opened this issue Jan 15, 2025 · 0 comments
Labels
Size/Days Some days of work Status/ReadyForDev The issue is ready to be developed or to be investigated deeply

Comments

@folmos-at-orange
Copy link
Member

folmos-at-orange commented Jan 15, 2025

Description

This is a pending refactoring suggested in PR #210. We postponed it to close the PR fast. There is no functional impact, it only reduces the code complexity.


(In file test/test_remote_access.py ~ L136)

To avoid using hasattr and setting up your own temporary urls, instead of a per test setup/tear-down, I'd use one for the whole class.

  • In the setupClass method you simply set the env var KHIOPS_TMP_DIR with a fresh runner.
  • In the tearDownClass method you clean up everything and restore the original temporary directory and runner.

Something like this example

import unittest
import os
import subprocess
from khiops import core as kh
from khiops.core.internals.runner import KhiopsLocalRunner


class TestWithAltRunner(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        # Save the original runner and temp dir
        cls.original_runner = kh.get_runner()
        cls.original_khiops_temp_dir = os.environ.get("KHIOPS_TMP_DIR")

        # Set the test suite temp dir
        os.environ["KHIOPS_TMP_DIR"] = "/tmp/mytmpdir/" # replace here with the URL
        cls.runner = KhiopsLocalRunner()
    @classmethod
    def tearDownClass(cls):
        # Restore the original runner and temp dir
        kh.set_runner(cls.original_runner)
        if cls.original_khiops_temp_dir is None:
            del os.environ["KHIOPS_TMP_DIR"]
        else:
            os.environ["KHIOPS_TMP_DIR"] = cls.original_khiops_temp_dir

        # Clean the whole alternative temporary file
        # ...

    def test(self):
        print("\n======= Current test runner =========")
        kh.get_runner().print_status()

Originally posted by @folmos-at-orange in #210 (comment)

@folmos-at-orange folmos-at-orange added Status/ReadyForDev The issue is ready to be developed or to be investigated deeply Type/DevChore Size/Days Some days of work labels Jan 15, 2025
@popescu-v popescu-v mentioned this issue Mar 12, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size/Days Some days of work Status/ReadyForDev The issue is ready to be developed or to be investigated deeply
Projects
None yet
Development

No branches or pull requests

1 participant