test_utils.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 """
3 ==============================================================================
4 
5  This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
6 
7  The GNSSTk is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published
9  by the Free Software Foundation; either version 3.0 of the License, or
10  any later version.
11 
12  The GNSSTk is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with GNSSTk; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 
21  This software was developed by Applied Research Laboratories at the
22  University of Texas at Austin.
23  Copyright 2004-2022, The Board of Regents of The University of Texas System
24 
25 ==============================================================================
26 
27 ==============================================================================
28 
29  This software was developed by Applied Research Laboratories at the
30  University of Texas at Austin, under contract to an agency or agencies
31  within the U.S. Department of Defense. The U.S. Government retains all
32  rights to use, duplicate, distribute, disclose, or release this software.
33 
34  Pursuant to DoD Directive 523024
35 
36  DISTRIBUTION STATEMENT A: This software has been approved for public
37  release, distribution is unlimited.
38 
39 ==============================================================================
40 """
41 import sys
42 import os
43 import argparse
44 import unittest
45 
46 import gnsstk
47 
48 args = None
49 
50 
52  """A function to run unit tests without using the argument parsing of
53  unittest.main() """
54 
55  parser = argparse.ArgumentParser(description="Test app for ctest")
56  parser.add_argument('-v,--verbose', dest='verbose', action='count',
57  help="Increase the amount of output generated by the program")
58  parser.add_argument('-o,--output_dir', dest='output_dir', metavar='dir',
59  help="Path to output directory")
60  parser.add_argument('-i,--input_dir', dest='input_dir', metavar='dir',
61  help="Path to root of input data directory")
62  global args
63  args=parser.parse_args()
64 
65  runner=unittest.TextTestRunner()
66 
67  # Find all Test classes in the parent script
68  script=os.path.basename(sys.argv[0])
69  dir=os.path.dirname(sys.argv[0])
70  isuite = unittest.TestLoader().discover(dir, pattern=script)
71 
72  rc = runner.run(isuite)
73  sys.exit(len(rc.failures) + len(rc.errors))
74 
75 
76 def assertSequenceAlmostEqual(test_case, l1, l2, **kwargs):
77  """
78  Compare two lists of elements where the elements are almost equal to each other
79 
80  Uses `assertAlmostEqual` to compare elements between `l1` and `l2`.
81  `l1` and `l2` must be equal in length.
82  """
83  test_case.assertEqual(len(l1), len(l2))
84  for l1_i, l2_i in zip(l1, l2):
85  test_case.assertAlmostEqual(l1_i, l2_i, **kwargs)
86 
87 
88 def vec_to_list(s):
89  """
90  A kludge since many swigged gnsstk objects are not properly iterable
91  """
92  return [s[i] for i in range(s.size())]
93 
test_utils.vec_to_list
def vec_to_list(s)
Definition: test_utils.py:88
test_utils.assertSequenceAlmostEqual
def assertSequenceAlmostEqual(test_case, l1, l2, **kwargs)
Definition: test_utils.py:76
gnsstk::range
double range(const Position &A, const Position &B)
Definition: Position.cpp:1273
test_utils.run_unit_tests
def run_unit_tests()
Definition: test_utils.py:51


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41