Render order enforcing
diff --git a/gym/utils/env_checker.py b/gym/utils/env_checker.py
index 19e4317c719..399c5b10e27 100644
--- a/gym/utils/env_checker.py
+++ b/gym/utils/env_checker.py
@@ -388,13 +388,6 @@ def check_env(env: gym.Env, warn: bool = True, skip_render_check: bool = True) -
     observation_space = env.observation_space
     action_space = env.action_space
 
-    try:
-        # As environments are normally wrapped by OrderEnforcing
-        # "Cannot call env.render() before calling env.reset()" is raised
-        env.step(env.action_space.sample())
-    except AssertionError as e:
-        assert "Cannot call env.step()" in str(e)
-
     # Warn the user if needed.
     # A warning means that the environment may run but not work properly with popular RL libraries.
     if warn:
diff --git a/gym/wrappers/order_enforcing.py b/gym/wrappers/order_enforcing.py
index 32e1f0b7149..4bb0720da9a 100644
--- a/gym/wrappers/order_enforcing.py
+++ b/gym/wrappers/order_enforcing.py
@@ -1,5 +1,6 @@
 """Wrapper to enforce the proper ordering of environment operations."""
 import gym
+from gym.error import ResetNeeded
 
 
 class OrderEnforcing(gym.Wrapper):
@@ -18,14 +19,21 @@ class OrderEnforcing(gym.Wrapper):
         >>> env.step(0)
     """
 
-    def __init__(self, env):
-        """A wrapper that will produce an error if :meth:`step` is called before an initial :meth:`reset`."""
+    def __init__(self, env: gym.Env, disable_render_order_enforcing: bool = False):
+        """A wrapper that will produce an error if :meth:`step` is called before an initial :meth:`reset`.
+
+        Args:
+            env: The environment to wrap
+            disable_render_order_enforcing: If to disable render order enforcing
+        """
         super().__init__(env)
-        self._has_reset = False
+        self._has_reset: bool = False
+        self._disable_render_order_enforcing: bool = disable_render_order_enforcing
 
     def step(self, action):
-        """Steps through the environment with :param:`kwargs`."""
-        assert self._has_reset, "Cannot call env.step() before calling env.reset()"
+        """Steps through the environment with `kwargs`."""
+        if not self._has_reset:
+            raise ResetNeeded("Cannot call env.step() before calling env.reset()")
         return self.env.step(action)
 
     def reset(self, **kwargs):
@@ -34,15 +42,10 @@ def reset(self, **kwargs):
         return self.env.reset(**kwargs)
 
     def render(self, **kwargs):
-        """Checks that the environment has been :meth:`reset` before rendering the environment."""
-        if hasattr(self.unwrapped, "disable_render_order_enforcing"):
-            if not self.unwrapped.disable_render_order_enforcing:
-                assert (
-                    self._has_reset
-                ), "Cannot call env.render() before calling env.reset()"
-        else:
-            assert self._has_reset, (
-                "Cannot call env.render() before calling env.reset(), if this is a intended property, "
-                "set `disable_render_order_enforcing=True` on the base environment (env.unwrapped)."
+        """Renders the environment with `kwargs`."""
+        if not self._disable_render_order_enforcing and not self._has_reset:
+            raise ResetNeeded(
+                "Cannot call `env.render()` before calling `env.reset()`, if this is a intended action, "
+                "set `disable_render_order_enforcing=True` on the OrderEnforcer wrapper."
             )
         return self.env.render(**kwargs)
diff --git a/tests/wrappers/test_order_enforcing.py b/tests/wrappers/test_order_enforcing.py
index 7225fd3437c..6b77344ce29 100644
--- a/tests/wrappers/test_order_enforcing.py
+++ b/tests/wrappers/test_order_enforcing.py
@@ -2,6 +2,7 @@
 
 import gym
 from gym.envs.classic_control import CartPoleEnv
+from gym.error import ResetNeeded
 from gym.wrappers import OrderEnforcing
 from tests.envs.spec_list import spec_list
 from tests.wrappers.utils import has_wrapper
@@ -9,12 +10,14 @@
 
 @pytest.mark.parametrize("spec", spec_list, ids=[spec.id for spec in spec_list])
 def test_gym_make_order_enforcing(spec):
+    """Checks that gym.make wrappers the environment with the OrderEnforcing wrapper."""
     env = gym.make(spec.id)
 
     assert has_wrapper(env, OrderEnforcing)
 
 
 def test_order_enforcing():
+    """Checks that the order enforcing works as expected, raising an error before reset is called and not after."""
     # The reason for not using gym.make is that all environments are by default wrapped in the order enforcing wrapper
     env = CartPoleEnv()
     assert not has_wrapper(env, OrderEnforcing)
@@ -22,19 +25,19 @@ def test_order_enforcing():
     # Assert that the order enforcing works for step and render before reset
     order_enforced_env = OrderEnforcing(env)
     assert order_enforced_env._has_reset is False
-    with pytest.raises(AssertionError):
+    with pytest.raises(ResetNeeded):
         order_enforced_env.step(0)
-    with pytest.raises(AssertionError):
-        order_enforced_env.render()
+    with pytest.raises(ResetNeeded):
+        order_enforced_env.render(mode="rgb_array")
+    assert order_enforced_env._has_reset is False
 
     # Assert that the Assertion errors are not raised after reset
     order_enforced_env.reset()
     assert order_enforced_env._has_reset is True
     order_enforced_env.step(0)
-    order_enforced_env.render()
+    order_enforced_env.render(mode="rgb_array")
 
-    # Assert that with disable_render_order_enforcing works
+    # Assert that with disable_render_order_enforcing works, the environment has already been reset
     env = CartPoleEnv()
-    env.disable_render_order_enforcing = True
-    env = OrderEnforcing(env)
-    env.render()  # no assertion error
+    env = OrderEnforcing(env, disable_render_order_enforcing=True)
+    env.render(mode="rgb_array")  # no assertion error
diff --git a/tests/wrappers/utils.py b/tests/wrappers/utils.py
index 63cee5a922a..55db8873af0 100644
--- a/tests/wrappers/utils.py
+++ b/tests/wrappers/utils.py
@@ -1,9 +1,7 @@
-from typing import Union
-
 import gym
 
 
-def has_wrapper(wrapped_env: Union[gym.Wrapper, gym.Env], wrapper_type: type):
+def has_wrapper(wrapped_env: gym.Env, wrapper_type: type) -> bool:
     while isinstance(wrapped_env, gym.Wrapper):
         if isinstance(wrapped_env, wrapper_type):
             return True

Add render order enforcement as most gym environments cannot be visualised before render
Inspired by https://github.com/openai/gym/issues/2751

As some users may want this as a feature of their environments, I have added a setting where if the users add `disable_render_order_enforcing` to the base environment then this will not be checked

Added tests to verify these features are working
Deleted old test that did not seem to actually test anything that `OrderEnforcing` actually implemented. 

This has also changed the error from `AssertationError` to `ResetNeeded` error