We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
working on fixing tests
## 🐛 Bug

here are some crazy observations that started from looking into the test failure in #923, and may have some implications for general test fixes that we want to look into in #921.  I'll patch it in a PR soon, but just want to document this somewhere, in case it becomes pertinent to #921

on a mac (but we observe it in linux tests too), with python 3.7, using pyqt5 (I'm on 5.14.1), running this code:
```python
import numpy as np
import pytest  # <-- this unused import is required for the bug!
import napari

with napari.gui_qt():
    data = np.random.random((10, 15, 20))
    viewer = napari.view_image(data)
    viewer = napari.view_image(data)
    viewer.dims.ndisplay = 3
    viewer.dims.ndisplay = 2
```
leads to an error deep in vispy that culminates in:
```
lib/python3.7/site-packages/vispy/gloo/glir.py in _validate(self)
   1299                                         gl.GL_VALIDATE_STATUS):
   1300             raise RuntimeError('Program validation error:\n%s'
-> 1301                                % gl.glGetProgramInfoLog(self._handle))
   1302 
   1303     def _post_draw(self):

RuntimeError: Program validation error:
```
observations:
- only happens with python 3.7; python 3.6 & 3.8 are fine
- only happens with pyqt5, not pyside2
- only happens with the **double** viewer instantiation (two calls to `view_image`), assigning both viewers to the same variable name.  If you name the second viewer `viewer2`, it's fine
- only happens when you switch from `ndisplay=` 2, then to 3, back to 2
- the error occurs only once per session.  running the same code a second time works fine.
- pytest is key.  if you comment out the `import pytest` line, you don't get the error...
- i thought it might have something to do with our adding of 'viewer' to console globals... but removing the `self.console = QtConsole({'viewer': self.viewer})` from our `QtConsole` instantiation doesn't change anything.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `napari/__init__.py`
Content:
```
1 from ._version import get_versions
2 
3 __version__ = get_versions()['version']
4 del get_versions
5 
6 import os
7 from distutils.version import StrictVersion
8 from pathlib import Path
9 from qtpy import API_NAME
10 from ._version import get_versions
11 
12 # putting up higher due to circular imports if plugin exceptions are raised
13 # on startup (we need to be able to show the napari version in the traceback.)
14 __version__ = get_versions()['version']
15 del get_versions
16 
17 
18 if API_NAME == 'PySide2':
19     # Set plugin path appropriately if using PySide2. This is a bug fix
20     # for when both PyQt5 and Pyside2 are installed
21     import PySide2
22 
23     os.environ['QT_PLUGIN_PATH'] = str(
24         Path(PySide2.__file__).parent / 'Qt' / 'plugins'
25     )
26 
27 from qtpy import QtCore
28 
29 # When QT is not the specific version, we raise a warning:
30 from warnings import warn
31 
32 if StrictVersion(QtCore.__version__) < StrictVersion('5.12.3'):
33     warn_message = f"""
34     napari was tested with QT library `>=5.12.3`.
35     The version installed is {QtCore.__version__}. Please report any issues with this
36     specific QT version at https://github.com/Napari/napari/issues.
37     """
38     warn(message=warn_message)
39 
40 from vispy import app
41 import logging
42 
43 # set vispy application to the appropriate qt backend
44 app.use_app(API_NAME)
45 del app
46 # set vispy logger to show warning and errors only
47 vispy_logger = logging.getLogger('vispy')
48 vispy_logger.setLevel(logging.WARNING)
49 
50 from .viewer import Viewer
51 from .plugins.io import save_layers
52 
53 # Note that importing _viewer_key_bindings is needed as the Viewer gets
54 # decorated with keybindings during that process, but it is not directly needed
55 # by our users and so is deleted below
56 from . import _viewer_key_bindings  # noqa: F401
57 from .view_layers import (
58     view_path,
59     view_image,
60     view_labels,
61     view_surface,
62     view_shapes,
63     view_points,
64     view_vectors,
65 )
66 from ._qt import gui_qt
67 from .utils import sys_info, _magicgui
68 
69 # register napari object types with magicgui if it is installed
70 _magicgui.register_types_with_magicgui()
71 
72 
73 # this unused import is here to fix a very strange bug.
74 # there is some mysterious magical goodness in scipy stats that needs
75 # to be imported early.
76 # see: https://github.com/napari/napari/issues/925
77 from scipy import stats  # noqa: F401
78 
79 del _magicgui
80 del stats
81 del _viewer_key_bindings
82
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/napari/__init__.py b/napari/__init__.py
--- a/napari/__init__.py
+++ b/napari/__init__.py
@@ -69,13 +69,5 @@
 # register napari object types with magicgui if it is installed
 _magicgui.register_types_with_magicgui()
 
-
-# this unused import is here to fix a very strange bug.
-# there is some mysterious magical goodness in scipy stats that needs
-# to be imported early.
-# see: https://github.com/napari/napari/issues/925
-from scipy import stats  # noqa: F401
-
 del _magicgui
-del stats
 del _viewer_key_bindings

{"golden_diff": "diff --git a/napari/__init__.py b/napari/__init__.py\n--- a/napari/__init__.py\n+++ b/napari/__init__.py\n@@ -69,13 +69,5 @@\n # register napari object types with magicgui if it is installed\n _magicgui.register_types_with_magicgui()\n \n-\n-# this unused import is here to fix a very strange bug.\n-# there is some mysterious magical goodness in scipy stats that needs\n-# to be imported early.\n-# see: https://github.com/napari/napari/issues/925\n-from scipy import stats  # noqa: F401\n-\n del _magicgui\n-del stats\n del _viewer_key_bindings\n", "issue": "working on fixing tests\n## \ud83d\udc1b Bug\r\n\r\nhere are some crazy observations that started from looking into the test failure in #923, and may have some implications for general test fixes that we want to look into in #921.  I'll patch it in a PR soon, but just want to document this somewhere, in case it becomes pertinent to #921\r\n\r\non a mac (but we observe it in linux tests too), with python 3.7, using pyqt5 (I'm on 5.14.1), running this code:\r\n```python\r\nimport numpy as np\r\nimport pytest  # <-- this unused import is required for the bug!\r\nimport napari\r\n\r\nwith napari.gui_qt():\r\n    data = np.random.random((10, 15, 20))\r\n    viewer = napari.view_image(data)\r\n    viewer = napari.view_image(data)\r\n    viewer.dims.ndisplay = 3\r\n    viewer.dims.ndisplay = 2\r\n```\r\nleads to an error deep in vispy that culminates in:\r\n```\r\nlib/python3.7/site-packages/vispy/gloo/glir.py in _validate(self)\r\n   1299                                         gl.GL_VALIDATE_STATUS):\r\n   1300             raise RuntimeError('Program validation error:\\n%s'\r\n-> 1301                                % gl.glGetProgramInfoLog(self._handle))\r\n   1302 \r\n   1303     def _post_draw(self):\r\n\r\nRuntimeError: Program validation error:\r\n```\r\nobservations:\r\n- only happens with python 3.7; python 3.6 & 3.8 are fine\r\n- only happens with pyqt5, not pyside2\r\n- only happens with the **double** viewer instantiation (two calls to `view_image`), assigning both viewers to the same variable name.  If you name the second viewer `viewer2`, it's fine\r\n- only happens when you switch from `ndisplay=` 2, then to 3, back to 2\r\n- the error occurs only once per session.  running the same code a second time works fine.\r\n- pytest is key.  if you comment out the `import pytest` line, you don't get the error...\r\n- i thought it might have something to do with our adding of 'viewer' to console globals... but removing the `self.console = QtConsole({'viewer': self.viewer})` from our `QtConsole` instantiation doesn't change anything.\r\n\n", "before_files": [{"content": "from ._version import get_versions\n\n__version__ = get_versions()['version']\ndel get_versions\n\nimport os\nfrom distutils.version import StrictVersion\nfrom pathlib import Path\nfrom qtpy import API_NAME\nfrom ._version import get_versions\n\n# putting up higher due to circular imports if plugin exceptions are raised\n# on startup (we need to be able to show the napari version in the traceback.)\n__version__ = get_versions()['version']\ndel get_versions\n\n\nif API_NAME == 'PySide2':\n    # Set plugin path appropriately if using PySide2. This is a bug fix\n    # for when both PyQt5 and Pyside2 are installed\n    import PySide2\n\n    os.environ['QT_PLUGIN_PATH'] = str(\n        Path(PySide2.__file__).parent / 'Qt' / 'plugins'\n    )\n\nfrom qtpy import QtCore\n\n# When QT is not the specific version, we raise a warning:\nfrom warnings import warn\n\nif StrictVersion(QtCore.__version__) < StrictVersion('5.12.3'):\n    warn_message = f\"\"\"\n    napari was tested with QT library `>=5.12.3`.\n    The version installed is {QtCore.__version__}. Please report any issues with this\n    specific QT version at https://github.com/Napari/napari/issues.\n    \"\"\"\n    warn(message=warn_message)\n\nfrom vispy import app\nimport logging\n\n# set vispy application to the appropriate qt backend\napp.use_app(API_NAME)\ndel app\n# set vispy logger to show warning and errors only\nvispy_logger = logging.getLogger('vispy')\nvispy_logger.setLevel(logging.WARNING)\n\nfrom .viewer import Viewer\nfrom .plugins.io import save_layers\n\n# Note that importing _viewer_key_bindings is needed as the Viewer gets\n# decorated with keybindings during that process, but it is not directly needed\n# by our users and so is deleted below\nfrom . import _viewer_key_bindings  # noqa: F401\nfrom .view_layers import (\n    view_path,\n    view_image,\n    view_labels,\n    view_surface,\n    view_shapes,\n    view_points,\n    view_vectors,\n)\nfrom ._qt import gui_qt\nfrom .utils import sys_info, _magicgui\n\n# register napari object types with magicgui if it is installed\n_magicgui.register_types_with_magicgui()\n\n\n# this unused import is here to fix a very strange bug.\n# there is some mysterious magical goodness in scipy stats that needs\n# to be imported early.\n# see: https://github.com/napari/napari/issues/925\nfrom scipy import stats  # noqa: F401\n\ndel _magicgui\ndel stats\ndel _viewer_key_bindings\n", "path": "napari/__init__.py"}], "after_files": [{"content": "from ._version import get_versions\n\n__version__ = get_versions()['version']\ndel get_versions\n\nimport os\nfrom distutils.version import StrictVersion\nfrom pathlib import Path\nfrom qtpy import API_NAME\nfrom ._version import get_versions\n\n# putting up higher due to circular imports if plugin exceptions are raised\n# on startup (we need to be able to show the napari version in the traceback.)\n__version__ = get_versions()['version']\ndel get_versions\n\n\nif API_NAME == 'PySide2':\n    # Set plugin path appropriately if using PySide2. This is a bug fix\n    # for when both PyQt5 and Pyside2 are installed\n    import PySide2\n\n    os.environ['QT_PLUGIN_PATH'] = str(\n        Path(PySide2.__file__).parent / 'Qt' / 'plugins'\n    )\n\nfrom qtpy import QtCore\n\n# When QT is not the specific version, we raise a warning:\nfrom warnings import warn\n\nif StrictVersion(QtCore.__version__) < StrictVersion('5.12.3'):\n    warn_message = f\"\"\"\n    napari was tested with QT library `>=5.12.3`.\n    The version installed is {QtCore.__version__}. Please report any issues with this\n    specific QT version at https://github.com/Napari/napari/issues.\n    \"\"\"\n    warn(message=warn_message)\n\nfrom vispy import app\nimport logging\n\n# set vispy application to the appropriate qt backend\napp.use_app(API_NAME)\ndel app\n# set vispy logger to show warning and errors only\nvispy_logger = logging.getLogger('vispy')\nvispy_logger.setLevel(logging.WARNING)\n\nfrom .viewer import Viewer\nfrom .plugins.io import save_layers\n\n# Note that importing _viewer_key_bindings is needed as the Viewer gets\n# decorated with keybindings during that process, but it is not directly needed\n# by our users and so is deleted below\nfrom . import _viewer_key_bindings  # noqa: F401\nfrom .view_layers import (\n    view_path,\n    view_image,\n    view_labels,\n    view_surface,\n    view_shapes,\n    view_points,\n    view_vectors,\n)\nfrom ._qt import gui_qt\nfrom .utils import sys_info, _magicgui\n\n# register napari object types with magicgui if it is installed\n_magicgui.register_types_with_magicgui()\n\ndel _magicgui\ndel _viewer_key_bindings\n", "path": "napari/__init__.py"}]}