You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importunittestimportosimportsubprocessfromkhiopsimportcoreaskhfromkhiops.core.internals.runnerimportKhiopsLocalRunnerclassTestWithAltRunner(unittest.TestCase):
@classmethoddefsetUpClass(cls):
# Save the original runner and temp dircls.original_runner=kh.get_runner()
cls.original_khiops_temp_dir=os.environ.get("KHIOPS_TMP_DIR")
# Set the test suite temp diros.environ["KHIOPS_TMP_DIR"] ="/tmp/mytmpdir/"# replace here with the URLcls.runner=KhiopsLocalRunner()
@classmethoddeftearDownClass(cls):
# Restore the original runner and temp dirkh.set_runner(cls.original_runner)
ifcls.original_khiops_temp_dirisNone:
delos.environ["KHIOPS_TMP_DIR"]
else:
os.environ["KHIOPS_TMP_DIR"] =cls.original_khiops_temp_dir# Clean the whole alternative temporary file# ...deftest(self):
print("\n======= Current test runner =========")
kh.get_runner().print_status()
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.setupClass
method you simply set the env varKHIOPS_TMP_DIR
with a fresh runner.tearDownClass
method you clean up everything and restore the original temporary directory and runner.Something like this example
Originally posted by @folmos-at-orange in #210 (comment)
The text was updated successfully, but these errors were encountered: