We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pytest is now a hidden hard dependency
<!--To help us understand and resolve your issue, please fill out the form to
the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

We now import `pytest` directly in `yt/testing.py`, but `pytest` is not yet listed as a hard dependency. This will cause a `ModuleNotFoundError` to be raised after installing yt until you install pytest manually.

I'm opening an issue rather than a PR because I don't know whether people would prefer to put the `pytest` import in a try block or make it a dependency.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `yt/__init__.py`
Content:
```
1 """
2 yt is a toolkit for analyzing and visualizing volumetric data.
3 
4 * Website: https://yt-project.org
5 * Documentation: https://yt-project.org/doc
6 * Data hub: https://girder.hub.yt
7 * Contribute: https://github.com/yt-project/yt
8 
9 """
10 __version__ = "4.1.dev0"
11 
12 import yt.units as units
13 import yt.utilities.physical_constants as physical_constants
14 from yt.data_objects.api import (
15     DatasetSeries,
16     ImageArray,
17     ParticleProfile,
18     Profile1D,
19     Profile2D,
20     Profile3D,
21     add_particle_filter,
22     create_profile,
23     particle_filter,
24 )
25 from yt.fields.api import (
26     DerivedField,
27     FieldDetector,
28     FieldInfoContainer,
29     ValidateDataField,
30     ValidateGridType,
31     ValidateParameter,
32     ValidateProperty,
33     ValidateSpatial,
34     add_field,
35     add_xray_emissivity_field,
36     derived_field,
37     field_plugins,
38 )
39 from yt.frontends.api import _frontend_container
40 from yt.funcs import (
41     enable_plugins,
42     get_memory_usage,
43     get_pbar,
44     get_version_stack,
45     get_yt_version,
46     insert_ipython,
47     is_root,
48     is_sequence,
49     memory_checker,
50     only_on_root,
51     parallel_profile,
52     print_tb,
53     rootonly,
54     toggle_interactivity,
55 )
56 from yt.units import (
57     YTArray,
58     YTQuantity,
59     display_ytarray,
60     loadtxt,
61     savetxt,
62     uconcatenate,
63     ucross,
64     udot,
65     uhstack,
66     uintersect1d,
67     unorm,
68     ustack,
69     uunion1d,
70     uvstack,
71 )
72 from yt.units.unit_object import define_unit  # type: ignore
73 from yt.utilities.logger import set_log_level, ytLogger as mylog
74 
75 frontends = _frontend_container()
76 
77 import yt.visualization.volume_rendering.api as volume_rendering
78 from yt.frontends.stream.api import hexahedral_connectivity
79 from yt.frontends.ytdata.api import save_as_dataset
80 from yt.loaders import (
81     load,
82     load_amr_grids,
83     load_archive,
84     load_hexahedral_mesh,
85     load_octree,
86     load_particles,
87     load_sample,
88     load_simulation,
89     load_uniform_grid,
90     load_unstructured_mesh,
91 )
92 from yt.testing import run_nose
93 from yt.units.unit_systems import UnitSystem, unit_system_registry  # type: ignore
94 
95 # Import some helpful math utilities
96 from yt.utilities.math_utils import ortho_find, periodic_position, quartiles
97 from yt.utilities.parallel_tools.parallel_analysis_interface import (
98     communication_system,
99     enable_parallelism,
100     parallel_objects,
101 )
102 
103 # Now individual component imports from the visualization API
104 from yt.visualization.api import (
105     AxisAlignedProjectionPlot,
106     AxisAlignedSlicePlot,
107     FITSImageData,
108     FITSOffAxisProjection,
109     FITSOffAxisSlice,
110     FITSParticleProjection,
111     FITSProjection,
112     FITSSlice,
113     FixedResolutionBuffer,
114     LineBuffer,
115     LinePlot,
116     OffAxisProjectionPlot,
117     OffAxisSlicePlot,
118     ParticleImageBuffer,
119     ParticlePhasePlot,
120     ParticlePlot,
121     ParticleProjectionPlot,
122     PhasePlot,
123     ProfilePlot,
124     ProjectionPlot,
125     SlicePlot,
126     add_colormap,
127     apply_colormap,
128     make_colormap,
129     plot_2d,
130     scale_image,
131     show_colormaps,
132     write_bitmap,
133     write_image,
134     write_projection,
135 )
136 from yt.visualization.volume_rendering.api import (
137     ColorTransferFunction,
138     TransferFunction,
139     create_scene,
140     off_axis_projection,
141     volume_render,
142 )
143 
144 #    TransferFunctionHelper, MultiVariateTransferFunction
145 #    off_axis_projection
146
```
--- 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/yt/__init__.py b/yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -89,7 +89,17 @@
     load_uniform_grid,
     load_unstructured_mesh,
 )
-from yt.testing import run_nose
+
+
+def run_nose(*args, **kwargs):
+    # we hide this function behind a closure so we
+    # don't make pytest a hard dependency for end users
+    # see https://github.com/yt-project/yt/issues/3771
+    from yt.testing import run_nose
+
+    return run_nose(*args, **kwargs)
+
+
 from yt.units.unit_systems import UnitSystem, unit_system_registry  # type: ignore
 
 # Import some helpful math utilities

{"golden_diff": "diff --git a/yt/__init__.py b/yt/__init__.py\n--- a/yt/__init__.py\n+++ b/yt/__init__.py\n@@ -89,7 +89,17 @@\n     load_uniform_grid,\n     load_unstructured_mesh,\n )\n-from yt.testing import run_nose\n+\n+\n+def run_nose(*args, **kwargs):\n+    # we hide this function behind a closure so we\n+    # don't make pytest a hard dependency for end users\n+    # see https://github.com/yt-project/yt/issues/3771\n+    from yt.testing import run_nose\n+\n+    return run_nose(*args, **kwargs)\n+\n+\n from yt.units.unit_systems import UnitSystem, unit_system_registry  # type: ignore\n \n # Import some helpful math utilities\n", "issue": "pytest is now a hidden hard dependency\n<!--To help us understand and resolve your issue, please fill out the form to\r\nthe best of your ability.-->\r\n<!--You can feel free to delete the sections that do not apply.-->\r\n\r\n### Bug report\r\n\r\nWe now import `pytest` directly in `yt/testing.py`, but `pytest` is not yet listed as a hard dependency. This will cause a `ModuleNotFoundError` to be raised after installing yt until you install pytest manually.\r\n\r\nI'm opening an issue rather than a PR because I don't know whether people would prefer to put the `pytest` import in a try block or make it a dependency.\n", "before_files": [{"content": "\"\"\"\nyt is a toolkit for analyzing and visualizing volumetric data.\n\n* Website: https://yt-project.org\n* Documentation: https://yt-project.org/doc\n* Data hub: https://girder.hub.yt\n* Contribute: https://github.com/yt-project/yt\n\n\"\"\"\n__version__ = \"4.1.dev0\"\n\nimport yt.units as units\nimport yt.utilities.physical_constants as physical_constants\nfrom yt.data_objects.api import (\n    DatasetSeries,\n    ImageArray,\n    ParticleProfile,\n    Profile1D,\n    Profile2D,\n    Profile3D,\n    add_particle_filter,\n    create_profile,\n    particle_filter,\n)\nfrom yt.fields.api import (\n    DerivedField,\n    FieldDetector,\n    FieldInfoContainer,\n    ValidateDataField,\n    ValidateGridType,\n    ValidateParameter,\n    ValidateProperty,\n    ValidateSpatial,\n    add_field,\n    add_xray_emissivity_field,\n    derived_field,\n    field_plugins,\n)\nfrom yt.frontends.api import _frontend_container\nfrom yt.funcs import (\n    enable_plugins,\n    get_memory_usage,\n    get_pbar,\n    get_version_stack,\n    get_yt_version,\n    insert_ipython,\n    is_root,\n    is_sequence,\n    memory_checker,\n    only_on_root,\n    parallel_profile,\n    print_tb,\n    rootonly,\n    toggle_interactivity,\n)\nfrom yt.units import (\n    YTArray,\n    YTQuantity,\n    display_ytarray,\n    loadtxt,\n    savetxt,\n    uconcatenate,\n    ucross,\n    udot,\n    uhstack,\n    uintersect1d,\n    unorm,\n    ustack,\n    uunion1d,\n    uvstack,\n)\nfrom yt.units.unit_object import define_unit  # type: ignore\nfrom yt.utilities.logger import set_log_level, ytLogger as mylog\n\nfrontends = _frontend_container()\n\nimport yt.visualization.volume_rendering.api as volume_rendering\nfrom yt.frontends.stream.api import hexahedral_connectivity\nfrom yt.frontends.ytdata.api import save_as_dataset\nfrom yt.loaders import (\n    load,\n    load_amr_grids,\n    load_archive,\n    load_hexahedral_mesh,\n    load_octree,\n    load_particles,\n    load_sample,\n    load_simulation,\n    load_uniform_grid,\n    load_unstructured_mesh,\n)\nfrom yt.testing import run_nose\nfrom yt.units.unit_systems import UnitSystem, unit_system_registry  # type: ignore\n\n# Import some helpful math utilities\nfrom yt.utilities.math_utils import ortho_find, periodic_position, quartiles\nfrom yt.utilities.parallel_tools.parallel_analysis_interface import (\n    communication_system,\n    enable_parallelism,\n    parallel_objects,\n)\n\n# Now individual component imports from the visualization API\nfrom yt.visualization.api import (\n    AxisAlignedProjectionPlot,\n    AxisAlignedSlicePlot,\n    FITSImageData,\n    FITSOffAxisProjection,\n    FITSOffAxisSlice,\n    FITSParticleProjection,\n    FITSProjection,\n    FITSSlice,\n    FixedResolutionBuffer,\n    LineBuffer,\n    LinePlot,\n    OffAxisProjectionPlot,\n    OffAxisSlicePlot,\n    ParticleImageBuffer,\n    ParticlePhasePlot,\n    ParticlePlot,\n    ParticleProjectionPlot,\n    PhasePlot,\n    ProfilePlot,\n    ProjectionPlot,\n    SlicePlot,\n    add_colormap,\n    apply_colormap,\n    make_colormap,\n    plot_2d,\n    scale_image,\n    show_colormaps,\n    write_bitmap,\n    write_image,\n    write_projection,\n)\nfrom yt.visualization.volume_rendering.api import (\n    ColorTransferFunction,\n    TransferFunction,\n    create_scene,\n    off_axis_projection,\n    volume_render,\n)\n\n#    TransferFunctionHelper, MultiVariateTransferFunction\n#    off_axis_projection\n", "path": "yt/__init__.py"}], "after_files": [{"content": "\"\"\"\nyt is a toolkit for analyzing and visualizing volumetric data.\n\n* Website: https://yt-project.org\n* Documentation: https://yt-project.org/doc\n* Data hub: https://girder.hub.yt\n* Contribute: https://github.com/yt-project/yt\n\n\"\"\"\n__version__ = \"4.1.dev0\"\n\nimport yt.units as units\nimport yt.utilities.physical_constants as physical_constants\nfrom yt.data_objects.api import (\n    DatasetSeries,\n    ImageArray,\n    ParticleProfile,\n    Profile1D,\n    Profile2D,\n    Profile3D,\n    add_particle_filter,\n    create_profile,\n    particle_filter,\n)\nfrom yt.fields.api import (\n    DerivedField,\n    FieldDetector,\n    FieldInfoContainer,\n    ValidateDataField,\n    ValidateGridType,\n    ValidateParameter,\n    ValidateProperty,\n    ValidateSpatial,\n    add_field,\n    add_xray_emissivity_field,\n    derived_field,\n    field_plugins,\n)\nfrom yt.frontends.api import _frontend_container\nfrom yt.funcs import (\n    enable_plugins,\n    get_memory_usage,\n    get_pbar,\n    get_version_stack,\n    get_yt_version,\n    insert_ipython,\n    is_root,\n    is_sequence,\n    memory_checker,\n    only_on_root,\n    parallel_profile,\n    print_tb,\n    rootonly,\n    toggle_interactivity,\n)\nfrom yt.units import (\n    YTArray,\n    YTQuantity,\n    display_ytarray,\n    loadtxt,\n    savetxt,\n    uconcatenate,\n    ucross,\n    udot,\n    uhstack,\n    uintersect1d,\n    unorm,\n    ustack,\n    uunion1d,\n    uvstack,\n)\nfrom yt.units.unit_object import define_unit  # type: ignore\nfrom yt.utilities.logger import set_log_level, ytLogger as mylog\n\nfrontends = _frontend_container()\n\nimport yt.visualization.volume_rendering.api as volume_rendering\nfrom yt.frontends.stream.api import hexahedral_connectivity\nfrom yt.frontends.ytdata.api import save_as_dataset\nfrom yt.loaders import (\n    load,\n    load_amr_grids,\n    load_archive,\n    load_hexahedral_mesh,\n    load_octree,\n    load_particles,\n    load_sample,\n    load_simulation,\n    load_uniform_grid,\n    load_unstructured_mesh,\n)\n\n\ndef run_nose(*args, **kwargs):\n    # we hide this function behind a closure so we\n    # don't make pytest a hard dependency for end users\n    # see https://github.com/yt-project/yt/issues/3771\n    from yt.testing import run_nose\n\n    return run_nose(*args, **kwargs)\n\n\nfrom yt.units.unit_systems import UnitSystem, unit_system_registry  # type: ignore\n\n# Import some helpful math utilities\nfrom yt.utilities.math_utils import ortho_find, periodic_position, quartiles\nfrom yt.utilities.parallel_tools.parallel_analysis_interface import (\n    communication_system,\n    enable_parallelism,\n    parallel_objects,\n)\n\n# Now individual component imports from the visualization API\nfrom yt.visualization.api import (\n    AxisAlignedProjectionPlot,\n    AxisAlignedSlicePlot,\n    FITSImageData,\n    FITSOffAxisProjection,\n    FITSOffAxisSlice,\n    FITSParticleProjection,\n    FITSProjection,\n    FITSSlice,\n    FixedResolutionBuffer,\n    LineBuffer,\n    LinePlot,\n    OffAxisProjectionPlot,\n    OffAxisSlicePlot,\n    ParticleImageBuffer,\n    ParticlePhasePlot,\n    ParticlePlot,\n    ParticleProjectionPlot,\n    PhasePlot,\n    ProfilePlot,\n    ProjectionPlot,\n    SlicePlot,\n    add_colormap,\n    apply_colormap,\n    make_colormap,\n    plot_2d,\n    scale_image,\n    show_colormaps,\n    write_bitmap,\n    write_image,\n    write_projection,\n)\nfrom yt.visualization.volume_rendering.api import (\n    ColorTransferFunction,\n    TransferFunction,\n    create_scene,\n    off_axis_projection,\n    volume_render,\n)\n\n#    TransferFunctionHelper, MultiVariateTransferFunction\n#    off_axis_projection\n", "path": "yt/__init__.py"}]}