#11420: make test suite pass with -B/DONTWRITEBYTECODE set.  Initial patch by Thomas Wouters.
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py
index c7a7d8f..b4d7e7d 100644
--- a/Lib/importlib/test/source/test_file_loader.py
+++ b/Lib/importlib/test/source/test_file_loader.py
@@ -127,7 +127,8 @@
         finally:
             os.unlink(file_path)
             pycache = os.path.dirname(imp.cache_from_source(file_path))
-            shutil.rmtree(pycache)
+            if os.path.exists(pycache):
+                shutil.rmtree(pycache)
 
     def test_timestamp_overflow(self):
         # When a modification timestamp is larger than 2**32, it should be