소스 검색

Merge pull request #218 from rodrigodelazcano/pytest_warns

fix pytest warns
Mark Towers 2 년 전
부모
커밋
fce61a86c7
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  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}")