uranusjr commented on code in PR #28378:
URL: https://github.com/apache/airflow/pull/28378#discussion_r1050081585


##########
tests/core/test_impersonation_tests.py:
##########
@@ -47,55 +46,33 @@
 logger = logging.getLogger(__name__)
 
 
-def mock_custom_module_path(path: str):
-    """
-    This decorator adds a path to sys.path to simulate running the current 
script with
-    the :envvar:`PYTHONPATH` environment variable set and sets the environment 
variable
-    :envvar:`PYTHONPATH` to change the module load directory for child scripts.
-    """
-
-    def wrapper(func):
-        @functools.wraps(func)
-        def decorator(*args, **kwargs):
-            copy_sys_path = deepcopy(sys.path)
-            sys.path.append(path)
-            try:
-                with unittest.mock.patch.dict("os.environ", {"PYTHONPATH": 
path}):
-                    return func(*args, **kwargs)
-            finally:
-                sys.path = copy_sys_path
-
-        return decorator
-
-    return wrapper
[email protected]
+def check_original_docker_image():
+    if not os.path.isfile("/.dockerenv") or 
os.environ.get("PYTHON_BASE_IMAGE") is None:
+        raise pytest.skip(
+            "Adding/removing a user as part of a test is very bad for host os "
+            "(especially if the user already existed to begin with on the OS), 
"
+            "therefore we check if we run inside a the official docker 
container "
+            "and only allow to run the test there. This is done by checking 
/.dockerenv file "
+            "(always present inside container) and checking for 
PYTHON_BASE_IMAGE variable."
+        )
+    yield

Review Comment:
   ```suggestion
   ```
   
   Not needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to