test_data_source.py 1003 Bytes
Newer Older
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
1
2
3
4
5
6
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
7
import os
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
8
9
10
11
12
import unittest

from omegaconf import OmegaConf
from pytorch3d.implicitron.dataset.data_source import ImplicitronDataSource
from pytorch3d.implicitron.tools.config import get_default_args
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
13
from tests.common_testing import get_tests_dir
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
14
15
16
17
18
19
20
21
22
23

DATA_DIR = get_tests_dir() / "implicitron/data"
DEBUG: bool = False


class TestDataSource(unittest.TestCase):
    def setUp(self):
        self.maxDiff = None

    def test_one(self):
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
24
25
26
27
28
29
        with unittest.mock.patch.dict(os.environ, {"CO3D_DATASET_ROOT": ""}):
            cfg = get_default_args(ImplicitronDataSource)
            yaml = OmegaConf.to_yaml(cfg, sort_keys=False)
            if DEBUG:
                (DATA_DIR / "data_source.yaml").write_text(yaml)
            self.assertEqual(yaml, (DATA_DIR / "data_source.yaml").read_text())