test_mavparm.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
4 """
5 Unit tests for the mavparm library
6 """
7 
8 from __future__ import print_function
9 import unittest
10 import os
11 
12 from pymavlink import mavparm
13 
14 class MAVParmDictTest(unittest.TestCase):
15 
16  """
17  Class to test MAVParmDict
18  """
19 
20  def __init__(self, *args, **kwargs):
21  """Constructor, set up some data that is reused in many tests"""
22  self.parms = mavparm.MAVParmDict()
23  self.parms['AFS_ACTION'] = 42
24  self.parms['PARAM1'] = 34.45
25  self.parms['PARAM2'] = 0
26  self.parms['PARAM3'] = -13.4
27  super(MAVParmDictTest, self).__init__(*args, **kwargs)
28 
29 
30  def test_dict(self):
31  """Test simple dict operations"""
32  self.parms['AFS_ACTION'] = 34
33 
34  assert self.parms['AFS_ACTION'] == 34
35  assert self.parms['PARAM1'] == 34.45
36 
37  def test_saveload(self):
38  """Test the saving and loading to file"""
39  self.parms.save('prms.txt')
40  assert os.path.isfile('prms.txt')
41 
42  newparms = mavparm.MAVParmDict()
43  newparms.load('prms.txt')
44  os.remove('prms.txt')
45 
46  assert newparms['AFS_ACTION'] == self.parms['AFS_ACTION']
47  assert newparms['PARAM3'] == self.parms['PARAM3']
48 
49 
50 
51  def test_showdiff(self):
52  """Test show and diff functions"""
53  self.parms.save('prms.txt')
54 
55  self.parms.show()
56 
57  self.parms.diff('prms.txt')
58 
59 if __name__ == '__main__':
60  unittest.main()
def __init__(self, args, kwargs)
Definition: test_mavparm.py:20


mavlink
Author(s): Lorenz Meier
autogenerated on Sun Jul 7 2019 03:22:07