I tried this but "unloading" modules this way did not work so I will stick to the current version.

```diff
diff --git a/IPython/core/tests/test_run.py b/IPython/core/tests/test_run.py
index dac65ed..71402a2 100644
--- a/IPython/core/tests/test_run.py
+++ b/IPython/core/tests/test_run.py
@@ -356,9 +356,7 @@ def writefile(self, name, content):
             f.write(textwrap.dedent(content))
 
     def setUp(self):
-        self.package = package = 'tmp{0}'.format(repr(random.random())[2:])
-        """Temporary valid python package name."""
-
+        self.package = package = 'testpkg'
         self.value = int(random.random() * 10000)
 
         self.tempdir = TemporaryDirectory()
@@ -381,6 +379,11 @@ def tearDown(self):
         sys.path[:] = [p for p in sys.path if p != self.tempdir.name]
         self.tempdir.cleanup()
 
+        for name in [(n.startswith(self.package) or
+                      n.startswith(self.package + '.'))
+                     for n in sys.modules]:
+            del sys.modules[name]
+
     def check_run_submodule(self, submodule, opts=''):
         _ip.magic('run {2} -m {0}.{1}'.format(self.package, submodule, opts))
         self.assertEqual(_ip.user_ns['x'], self.value,
```