Skip to content

Commit

Permalink
Renderer must be created in optional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamenot committed Mar 5, 2022
1 parent 4d8f6c7 commit 5acafbe
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions smarts/core/tests/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
from smarts.core.sumo_traffic_simulation import SumoTrafficSimulation
from smarts.core.vehicle import RendererException

AGENT_ID = "Agent-007"


def _smarts_with_agent(agent) -> SMARTS:
agents = {"Agent-007": agent}
agents = {AGENT_ID: agent}
return SMARTS(
agents,
traffic_sim=SumoTrafficSimulation(headless=True),
Expand Down Expand Up @@ -87,7 +89,7 @@ def scenario():
scenario = Scenario(
scenario_root="scenarios/loop",
route="basic.rou.xml",
missions={"Agent-007": mission},
missions={AGENT_ID: mission},
)
return scenario

Expand Down Expand Up @@ -145,16 +147,15 @@ def test_multiple_renderers(scenario, request):
def test_optional_renderer(smarts: SMARTS, scenario):
assert not smarts.is_rendering
renderer = smarts.renderer
if not renderer:
raise RendererException.required_to("run test_renderer.py")
assert renderer

smarts._renderer = None
smarts.reset(scenario)
assert smarts.is_rendering

smarts._renderer = None
for _ in range(10):
smarts.step({"Agent-007": "keep_lane"})
smarts.step({AGENT_ID: "keep_lane"})

assert not smarts.is_rendering

Expand All @@ -164,6 +165,6 @@ def test_no_renderer(smarts_wo_renderer: SMARTS, scenario):
smarts_wo_renderer.reset(scenario)
assert not smarts_wo_renderer.is_rendering
for _ in range(10):
smarts_wo_renderer.step({"Agent-007": "keep_lane"})
smarts_wo_renderer.step({AGENT_ID: "keep_lane"})

assert not smarts_wo_renderer.is_rendering

0 comments on commit 5acafbe

Please sign in to comment.