diff --git a/test/dynamo/cpython/3_13/test_exception_variations.py b/test/dynamo/cpython/3_13/test_exception_variations.py
index a83a41d2975..c2d6eb3a41a 100644
--- a/test/dynamo/cpython/3_13/test_exception_variations.py
+++ b/test/dynamo/cpython/3_13/test_exception_variations.py
@@ -1,7 +1,62 @@
+# ======= BEGIN Dynamo patch =======
+# Owner(s): ["module: dynamo"]
 
+# ruff: noqa
+# flake8: noqa
+
+# Test copied from
+# https://raw.githubusercontent.com/python/cpython/refs/tags/v3.13.5/Lib/test/test_exception_variations.py
+
+import sys
+import torch
+import torch._dynamo.test_case
 import unittest
+from torch._dynamo.test_case import CPythonTestCase
+from torch.testing._internal.common_utils import (
+    run_tests,
+    xfailIfTorchDynamo,
+)
+
+__TestCase = CPythonTestCase
+
+# redirect import statements
+import sys
+import importlib.abc
+
+redirect_imports = (
+    "test.mapping_tests",
+    "test.typinganndata",
+    "test.test_grammar",
+    "test.test_math",
+    "test.test_iter",
+    "test.typinganndata.ann_module",
+)
+
+class RedirectImportFinder(importlib.abc.MetaPathFinder):
+    def find_spec(self, fullname, path, target=None):
+        # Check if the import is the problematic one
+        if fullname in redirect_imports:
+            try:
+                # Attempt to import the standalone module
+                name = fullname.removeprefix("test.")
+                r = importlib.import_module(name)
+                # Redirect the module in sys.modules
+                sys.modules[fullname] = r
+                # Return a module spec from the found module
+                return importlib.util.find_spec(name)
+            except ImportError:
+                return None
+        return None
+
+# Add the custom finder to sys.meta_path
+sys.meta_path.insert(0, RedirectImportFinder())
+
 
-class ExceptTestCases(unittest.TestCase):
+# ======= END DYNAMO PATCH =======
+
+import unittest
+
+class ExceptTestCases(__TestCase):
     def test_try_except_else_finally(self):
         hit_except = False
         hit_else = False
@@ -294,282 +349,5 @@ class ExceptTestCases(unittest.TestCase):
         self.assertTrue(hit_except)
 
 
-class ExceptStarTestCases(unittest.TestCase):
-    def test_try_except_else_finally(self):
-        hit_except = False
-        hit_else = False
-        hit_finally = False
-
-        try:
-            raise Exception('nyaa!')
-        except* BaseException:
-            hit_except = True
-        else:
-            hit_else = True
-        finally:
-            hit_finally = True
-
-        self.assertTrue(hit_except)
-        self.assertTrue(hit_finally)
-        self.assertFalse(hit_else)
-
-    def test_try_except_else_finally_no_exception(self):
-        hit_except = False
-        hit_else = False
-        hit_finally = False
-
-        try:
-            pass
-        except* BaseException:
-            hit_except = True
-        else:
-            hit_else = True
-        finally:
-            hit_finally = True
-
-        self.assertFalse(hit_except)
-        self.assertTrue(hit_finally)
-        self.assertTrue(hit_else)
-
-    def test_try_except_finally(self):
-        hit_except = False
-        hit_finally = False
-
-        try:
-            raise Exception('yarr!')
-        except* BaseException:
-            hit_except = True
-        finally:
-            hit_finally = True
-
-        self.assertTrue(hit_except)
-        self.assertTrue(hit_finally)
-
-    def test_try_except_finally_no_exception(self):
-        hit_except = False
-        hit_finally = False
-
-        try:
-            pass
-        except* BaseException:
-            hit_except = True
-        finally:
-            hit_finally = True
-
-        self.assertFalse(hit_except)
-        self.assertTrue(hit_finally)
-
-    def test_try_except(self):
-        hit_except = False
-
-        try:
-            raise Exception('ahoy!')
-        except* BaseException:
-            hit_except = True
-
-        self.assertTrue(hit_except)
-
-    def test_try_except_no_exception(self):
-        hit_except = False
-
-        try:
-            pass
-        except* BaseException:
-            hit_except = True
-
-        self.assertFalse(hit_except)
-
-    def test_try_except_else(self):
-        hit_except = False
-        hit_else = False
-
-        try:
-            raise Exception('foo!')
-        except* BaseException:
-            hit_except = True
-        else:
-            hit_else = True
-
-        self.assertFalse(hit_else)
-        self.assertTrue(hit_except)
-
-    def test_try_except_else_no_exception(self):
-        hit_except = False
-        hit_else = False
-
-        try:
-            pass
-        except* BaseException:
-            hit_except = True
-        else:
-            hit_else = True
-
-        self.assertFalse(hit_except)
-        self.assertTrue(hit_else)
-
-    def test_try_finally_no_exception(self):
-        hit_finally = False
-
-        try:
-            pass
-        finally:
-            hit_finally = True
-
-        self.assertTrue(hit_finally)
-
-    def test_nested(self):
-        hit_finally = False
-        hit_inner_except = False
-        hit_inner_finally = False
-
-        try:
-            try:
-                raise Exception('inner exception')
-            except* BaseException:
-                hit_inner_except = True
-            finally:
-                hit_inner_finally = True
-        finally:
-            hit_finally = True
-
-        self.assertTrue(hit_inner_except)
-        self.assertTrue(hit_inner_finally)
-        self.assertTrue(hit_finally)
-
-    def test_nested_else(self):
-        hit_else = False
-        hit_finally = False
-        hit_except = False
-        hit_inner_except = False
-        hit_inner_else = False
-
-        try:
-            try:
-                pass
-            except* BaseException:
-                hit_inner_except = True
-            else:
-                hit_inner_else = True
-
-            raise Exception('outer exception')
-        except* BaseException:
-            hit_except = True
-        else:
-            hit_else = True
-        finally:
-            hit_finally = True
-
-        self.assertFalse(hit_inner_except)
-        self.assertTrue(hit_inner_else)
-        self.assertFalse(hit_else)
-        self.assertTrue(hit_finally)
-        self.assertTrue(hit_except)
-
-    def test_nested_mixed1(self):
-        hit_except = False
-        hit_finally = False
-        hit_inner_except = False
-        hit_inner_finally = False
-
-        try:
-            try:
-                raise Exception('inner exception')
-            except* BaseException:
-                hit_inner_except = True
-            finally:
-                hit_inner_finally = True
-        except:
-            hit_except = True
-        finally:
-            hit_finally = True
-
-        self.assertTrue(hit_inner_except)
-        self.assertTrue(hit_inner_finally)
-        self.assertFalse(hit_except)
-        self.assertTrue(hit_finally)
-
-    def test_nested_mixed2(self):
-        hit_except = False
-        hit_finally = False
-        hit_inner_except = False
-        hit_inner_finally = False
-
-        try:
-            try:
-                raise Exception('inner exception')
-            except:
-                hit_inner_except = True
-            finally:
-                hit_inner_finally = True
-        except* BaseException:
-            hit_except = True
-        finally:
-            hit_finally = True
-
-        self.assertTrue(hit_inner_except)
-        self.assertTrue(hit_inner_finally)
-        self.assertFalse(hit_except)
-        self.assertTrue(hit_finally)
-
-
-    def test_nested_else_mixed1(self):
-        hit_else = False
-        hit_finally = False
-        hit_except = False
-        hit_inner_except = False
-        hit_inner_else = False
-
-        try:
-            try:
-                pass
-            except* BaseException:
-                hit_inner_except = True
-            else:
-                hit_inner_else = True
-
-            raise Exception('outer exception')
-        except:
-            hit_except = True
-        else:
-            hit_else = True
-        finally:
-            hit_finally = True
-
-        self.assertFalse(hit_inner_except)
-        self.assertTrue(hit_inner_else)
-        self.assertFalse(hit_else)
-        self.assertTrue(hit_finally)
-        self.assertTrue(hit_except)
-
-    def test_nested_else_mixed2(self):
-        hit_else = False
-        hit_finally = False
-        hit_except = False
-        hit_inner_except = False
-        hit_inner_else = False
-
-        try:
-            try:
-                pass
-            except:
-                hit_inner_except = True
-            else:
-                hit_inner_else = True
-
-            raise Exception('outer exception')
-        except* BaseException:
-            hit_except = True
-        else:
-            hit_else = True
-        finally:
-            hit_finally = True
-
-        self.assertFalse(hit_inner_except)
-        self.assertTrue(hit_inner_else)
-        self.assertFalse(hit_else)
-        self.assertTrue(hit_finally)
-        self.assertTrue(hit_except)
-
-
 if __name__ == '__main__':
-    unittest.main()
+    run_tests()
