This commit is contained in:
@@ -7,16 +7,19 @@ import requests
|
|||||||
|
|
||||||
def import_registrator_safely(monkeypatch):
|
def import_registrator_safely(monkeypatch):
|
||||||
"""
|
"""
|
||||||
registrator.py configure logging.basicConfig(filename='/sdsat/logs/..') au top-level.
|
Neutralise logging.basicConfig avant import pour éviter
|
||||||
En CI, ce chemin peut ne pas exister et casser l'import.
|
les erreurs liées au fichier de log.
|
||||||
On neutralise basicConfig avant import.
|
Importe scripts.registrator (car le fichier est dans scripts/).
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(logging, "basicConfig", lambda *args, **kwargs: None)
|
monkeypatch.setattr(logging, "basicConfig", lambda *args, **kwargs: None)
|
||||||
|
|
||||||
if "registrator" in sys.modules:
|
module_name = "scripts.registrator"
|
||||||
del sys.modules["registrator"]
|
|
||||||
|
if module_name in sys.modules:
|
||||||
|
del sys.modules[module_name]
|
||||||
|
|
||||||
|
return importlib.import_module(module_name)
|
||||||
|
|
||||||
return importlib.import_module("registrator")
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_hostname_success(monkeypatch):
|
def test_get_hostname_success(monkeypatch):
|
||||||
|
|||||||
Reference in New Issue
Block a user