How to use _get_regex_from_include_list method in stestr

Best Python code snippet using stestr_python

test_selection.py

Source:test_selection.py Github

copy

Full Screen

...99 include_list.seek(0)100 with mock.patch('builtins.open',101 return_value=include_list):102 with mock.patch('sys.exit') as mock_exit:103 selection._get_regex_from_include_list('fake_path')104 mock_exit.assert_called_once_with(5)105 def test_inclusion_exclusion_list_re(self):106 include_list = [re.compile('fake_test1'), re.compile('fake_test2')]107 test_lists = ['fake_test1[tg]', 'fake_test2[spam]',108 'fake_test3[tg,foo]', 'fake_test4[spam]']109 exclude_list = [(re.compile('spam'), 'spam not liked', [])]110 include_getter = 'stestr.selection._get_regex_from_include_list'111 with mock.patch(include_getter,112 return_value=include_list):113 with mock.patch('stestr.selection.exclusion_reader',114 return_value=exclude_list):115 result = selection.construct_list(116 test_lists, exclude_list='exclude_file',117 include_list='include_file', regexes=['foo'])...

Full Screen

Full Screen

selection.py

Source:selection.py Github

copy

Full Screen

...60 print("Invalid regex: %s in provided exclusion list file" %61 line_regex, file=sys.stderr)62 sys.exit(5)63 return regex_comment_lst64def _get_regex_from_include_list(file_path):65 lines = []66 for line in open(file_path).read().splitlines():67 split_line = line.strip().split('#')68 # Before the # is the regex69 line_regex = split_line[0].strip()70 if line_regex:71 try:72 lines.append(re.compile(line_regex))73 except re.error:74 print("Invalid regex: %s in provided inclusion_list file" %75 line_regex, file=sys.stderr)76 sys.exit(5)77 return lines78def construct_list(test_ids, regexes=None, exclude_list=None,79 include_list=None, exclude_regex=None):80 """Filters the discovered test cases81 :param list test_ids: The set of test_ids to be filtered82 :param list regexes: A list of regex filters to apply to the test_ids. The83 output will contain any test_ids which have a re.search() match for any84 of the regexes in this list. If this is None all test_ids will be85 returned86 :param str exclude_list: The path to an exclusion_list file87 :param str include_list: The path to an inclusion_list file88 :param str exclude_regex: regex pattern to exclude tests89 :return: iterable of strings. The strings are full90 test_ids91 :rtype: set92 """93 if not regexes:94 regexes = None # handle the other false things95 safe_re = None96 if include_list:97 safe_re = _get_regex_from_include_list(include_list)98 if not regexes and safe_re:99 regexes = safe_re100 elif regexes and safe_re:101 regexes += safe_re102 if exclude_list:103 exclude_data = exclusion_reader(exclude_list)104 else:105 exclude_data = None106 if exclude_regex:107 msg = "Skipped because of regexp provided as a command line argument:"108 try:109 record = (re.compile(exclude_regex), msg, [])110 except re.error:111 print("Invalid regex: %s used for exclude_regex" %...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stestr automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful