Browse Source

Merge pull request #218 from rodrigodelazcano/pytest_warns

fix pytest warns
Mark Towers 2 years ago
parent
commit
fce61a86c7
1 changed files with 5 additions and 4 deletions
  1. 5 4
      tests/test_envs.py

+ 5 - 4
tests/test_envs.py

@@ -1,3 +1,5 @@
+import warnings
+
 import gym
 import numpy as np
 import pytest
@@ -26,12 +28,11 @@ CHECK_ENV_IGNORE_WARNINGS = [
 def test_env(spec):
     # Capture warnings
     env = spec.make(disable_env_checker=True).unwrapped
-
+    warnings.simplefilter("always")
     # Test if env adheres to Gym API
-    with pytest.warns() as warnings:
+    with warnings.catch_warnings(record=True) as w:
         check_env(env)
-
-    for warning in warnings.list:
+    for warning in w:
         if warning.message.args[0] not in CHECK_ENV_IGNORE_WARNINGS:
             raise gym.error.Error(f"Unexpected warning: {warning.message}")