Skip to content

Commit

Permalink
[BugFix]--bypass test_sensor tests if no torch is found. (#1559)
Browse files Browse the repository at this point in the history
* --bypass test if no torch is found.
  • Loading branch information
jturner65 committed Nov 3, 2021
1 parent b1c5583 commit 20e0d9c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import importlib.util
import itertools
import json
from os import path as osp
Expand All @@ -18,6 +19,9 @@
from examples.settings import make_cfg
from habitat_sim.utils.common import quat_from_coeffs

torch_spec = importlib.util.find_spec("torch")
_HAS_TORCH = torch_spec is not None


def _render_scene(sim, scene, sensor_type, gpu2gpu):
gt_data_pose_file = osp.abspath(
Expand Down Expand Up @@ -152,8 +156,7 @@ def test_sensors(
):
if not osp.exists(scene):
pytest.skip("Skipping {}".format(scene))

if not habitat_sim.cuda_enabled and gpu2gpu:
if gpu2gpu and (not habitat_sim.cuda_enabled or not _HAS_TORCH):
pytest.skip("Skipping GPU->GPU test")

# We only support adding more RGB Sensors if one is already in a scene
Expand Down Expand Up @@ -259,8 +262,7 @@ def test_smoke_no_sensors(make_cfg_settings):
def test_smoke_redwood_noise(scene, gpu2gpu, make_cfg_settings):
if not osp.exists(scene):
pytest.skip("Skipping {}".format(scene))

if not habitat_sim.cuda_enabled and gpu2gpu:
if gpu2gpu and (not habitat_sim.cuda_enabled or not _HAS_TORCH):
pytest.skip("Skipping GPU->GPU test")

make_cfg_settings["depth_sensor"] = True
Expand Down

0 comments on commit 20e0d9c

Please sign in to comment.