|
4 | 4 | Tests all aspects of the MuJoCo MCP RL integration |
5 | 5 | """ |
6 | 6 |
|
| 7 | +import importlib.util |
7 | 8 | import sys |
8 | 9 | import time |
9 | 10 | import numpy as np |
10 | 11 | import logging |
11 | 12 | from pathlib import Path |
12 | 13 | from typing import Dict, Any |
13 | 14 |
|
| 15 | +import pytest |
| 16 | + |
14 | 17 | # Add src to path for imports |
15 | 18 | REPO_ROOT = Path(__file__).resolve().parents[2] |
16 | 19 | sys.path.insert(0, str(REPO_ROOT / "src")) |
17 | 20 | sys.path.insert(0, str(REPO_ROOT)) |
18 | 21 |
|
19 | | -try: |
20 | | - from mujoco_mcp.rl_integration import ( |
21 | | - RLConfig, MuJoCoRLEnvironment, RLTrainer, |
22 | | - ReachingTaskReward, BalancingTaskReward, WalkingTaskReward, |
23 | | - create_reaching_env, create_balancing_env, create_walking_env, |
24 | | - example_training |
25 | | - ) |
26 | | - from mujoco_mcp.viewer_client import MuJoCoViewerClient |
27 | | - from mujoco_mcp.simulation import MuJoCoSimulation |
28 | | -except ImportError as e: |
29 | | - print(f"❌ Import Error: {e}") |
30 | | - print("Make sure MuJoCo MCP is properly installed") |
31 | | - sys.exit(1) |
| 22 | +if importlib.util.find_spec("gymnasium") is None: |
| 23 | + pytest.skip("gymnasium is required for RL integration tests", allow_module_level=True) |
| 24 | + |
| 25 | +from mujoco_mcp.rl_integration import ( |
| 26 | + RLConfig, MuJoCoRLEnvironment, RLTrainer, |
| 27 | + ReachingTaskReward, BalancingTaskReward, WalkingTaskReward, |
| 28 | + create_reaching_env, create_balancing_env, create_walking_env, |
| 29 | + example_training |
| 30 | +) |
| 31 | +from mujoco_mcp.viewer_client import MuJoCoViewerClient |
| 32 | +from mujoco_mcp.simulation import MuJoCoSimulation |
32 | 33 |
|
33 | 34 | # Configure logging |
34 | 35 | logging.basicConfig(level=logging.INFO) |
|
0 commit comments