test_load_dsdl.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2014-2015 UAVCAN Development Team <uavcan.org>
3 # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 #
5 # This software is distributed under the terms of the MIT License.
6 #
7 # Author: Ben Dyer <ben_dyer@mac.com>
8 # Pavel Kirienko <pavel.kirienko@zubax.com>
9 #
10 
11 import unittest
12 import os
13 from pyuavcan_v0.dsdl import signature
14 from pyuavcan_v0.dsdl.common import DsdlException
15 from pyuavcan_v0 import load_dsdl
16 
17 
18 class TestLoadDsdl(unittest.TestCase):
19  '''
20  Unittests of the load_dsdl method.
21  '''
22 
23  def test_reload(self):
24  '''
25  Test calling load_dsdl again (after it is called by the uavcan module)
26  '''
27  ns0_dir = '{}/fake_dsdl/ns0_base/ns0'.format(os.path.dirname(__file__))
28  load_dsdl(ns0_dir, exclude_dist=True)
29  import pyuavcan_v0
30  test_type = pyuavcan_v0.thirdparty.ns0.Type0()
31  self.assertEqual(test_type.field0, 0)
32 
34  '''
35  Test calling load_dsdl with paths that contain two different types
36  with the same id.
37  '''
38  ns0_dir = '{}/fake_dsdl/ns0_base/ns0'.format(os.path.dirname(__file__))
39  ns0_dir_with_redefinition = '{}/fake_dsdl/ns0_redefined/ns0'.format(os.path.dirname(__file__))
40  try:
41  load_dsdl(ns0_dir, ns0_dir_with_redefinition, exclude_dist=True)
42  except DsdlException as e:
43  self.assertTrue(e.args[0].startswith("Redefinition of data type ID"))
44 
46  '''
47  Test calling load_dsdl with paths that contain the same type.
48  '''
49  ns0_dir = '{}/fake_dsdl/ns0_base/ns0'.format(os.path.dirname(__file__))
50  ns0_dir_with_redefinition = '{}/fake_dsdl/ns0_duplicated/ns0'.format(os.path.dirname(__file__))
51  load_dsdl(ns0_dir, ns0_dir_with_redefinition, exclude_dist=True)
pyuavcan_v0.load_dsdl
def load_dsdl(*paths, **args)
Definition: pyuavcan/pyuavcan_v0/__init__.py:105
dsdl.test_load_dsdl.TestLoadDsdl.test_reload_with_redefinition
def test_reload_with_redefinition(self)
Definition: test_load_dsdl.py:33
dsdl.test_load_dsdl.TestLoadDsdl.test_reload_with_duplication
def test_reload_with_duplication(self)
Definition: test_load_dsdl.py:45
dsdl.test_load_dsdl.TestLoadDsdl
Definition: test_load_dsdl.py:18
pyuavcan_v0.dsdl
Definition: pyuavcan/pyuavcan_v0/dsdl/__init__.py:1
dsdl.test_load_dsdl.TestLoadDsdl.test_reload
def test_reload(self)
Definition: test_load_dsdl.py:23
pyuavcan_v0.dsdl.common
Definition: dsdl/common.py:1
test.format
format
Definition: dsdl/test.py:6


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:03