From a61fb992a51218f3f77cba733222af28634ac682 2021-05-07 18:01:04
From: Sammy Al Hashemi <salhashemi2@bloomberg.net>
Date: 2021-05-07 18:01:04
Subject: [PATCH] Adding test for magic warnings

---

diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py
index 84bea9c..9092ce5 100644
--- a/IPython/core/tests/test_interactiveshell.py
+++ b/IPython/core/tests/test_interactiveshell.py
@@ -600,9 +600,16 @@ class TestSystemRaw(ExitCodeChecks):
         try:
             self.system("sleep 1 # wont happen")
         except KeyboardInterrupt:
-            self.fail("system call should intercept "
-                      "keyboard interrupt from subprocess.call")
-        self.assertEqual(ip.user_ns['_exit_code'], -signal.SIGINT)
+            self.fail(
+                "system call should intercept "
+                "keyboard interrupt from subprocess.call"
+            )
+        self.assertEqual(ip.user_ns["_exit_code"], -signal.SIGINT)
+
+    def test_magic_warnings(self):
+        for magic_cmd in ("ls", "pip", "conda", "cd"):
+            with self.assertWarnsRegex(Warning, "You executed the system command"):
+                ip.system_raw(magic_cmd)
 
 # TODO: Exit codes are currently ignored on Windows.
 class TestSystemPipedExitCode(ExitCodeChecks):