__init__.py
Go to the documentation of this file.
1 # coding=utf-8
2 import os
3 from distutils.version import LooseVersion
4 import pytest
5 import rospy
6 
7 
8 def get_output_file(argv):
9  for arg in argv:
10  if arg.startswith('--gtest_output'):
11  return arg.split('=xml:')[1]
12 
13  raise RuntimeError('No output file has been passed')
14 
15 
17  args = []
18  for arg in argv[1:]:
19  if arg.startswith('__') or arg.startswith('--gtest_output'):
20  continue
21  if arg in ['-t', '--text']:
22  arg = '-s' # pytest alias for --capture=no
23  args.append(arg)
24  return args
25 
26 
27 def create_cache_dir_args(version, output_file):
28  # disable cache for Pytest < 3.2
29  if LooseVersion("3.5.0") > LooseVersion(version):
30  cache_dir_arg = '-p no:cacheprovider'
31  else:
32  root_dir = os.path.dirname(output_file)
33  cache_dir_arg = '--rootdir={}'.format(root_dir)
34  return cache_dir_arg.split(' ')
35 
36 
37 def run_pytest(argv):
38  output_file = get_output_file(argv)
39  additional_args = get_additional_args(argv)
40  test_module = rospy.get_param('test_module')
41  module_path = os.path.realpath(test_module)
42  cache_dir_args = create_cache_dir_args(pytest.__version__, output_file)
43 
44  return pytest.main(
45  [module_path, '--junitxml={}'.format(output_file)]
46  + cache_dir_args
47  + additional_args
48  )
ros_pytest.run_pytest
def run_pytest(argv)
Definition: __init__.py:37
ros_pytest.create_cache_dir_args
def create_cache_dir_args(version, output_file)
Definition: __init__.py:27
ros_pytest.get_additional_args
def get_additional_args(argv)
Definition: __init__.py:16
ros_pytest.get_output_file
def get_output_file(argv)
Definition: __init__.py:8


ros_pytest
Author(s):
autogenerated on Wed Mar 8 2023 03:16:33