# Path: stestr/selection.py
# def filter_tests(filters, test_ids):
#     def include(test_id):
# def exclusion_reader(exclude_list):
# def _get_regex_from_include_list(file_path):
# def construct_list(test_ids, regexes=None, exclude_list=None,
#                    include_list=None, exclude_regex=None):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


import io
import re
from unittest import mock
from stestr import selection
from stestr.tests import base
            self.assertRaises(ImportError, selection.filter_tests,
                              ['fake_regex_with_bad_part[The-BAD-part]'],
                              test_list)
            mock_exit.assert_called_once_with(5)


class TestExclusionReader(base.TestCase):

    def test_exclusion_reader(self):
        exclude_list = io.StringIO()
        for i in range(4):
            exclude_list.write('fake_regex_%s\n' % i)
            exclude_list.write('fake_regex_with_note_%s # note\n' % i)
        exclude_list.seek(0)
        with mock.patch('builtins.open',
                        return_value=exclude_list):
            result = selection.exclusion_reader('fake_path')
        self.assertEqual(2 * 4, len(result))
        note_cnt = 0
        # not assuming ordering, mainly just testing the type
        for r in result:
            self.assertEqual(r[2], [])
            if r[1] == 'note':
                note_cnt += 1
            self.assertIn('search', dir(r[0]))  # like a compiled regexp
        self.assertEqual(note_cnt, 4)

    def test_invalid_regex(self):
        exclude_list = io.StringIO()
        exclude_list.write("fake_regex_with_bad_part[The-BAD-part]")

# Path: stestr/selection.py
# def filter_tests(filters, test_ids):
#     def include(test_id):
# def exclusion_reader(exclude_list):
# def _get_regex_from_include_list(file_path):
# def construct_list(test_ids, regexes=None, exclude_list=None,
#                    include_list=None, exclude_regex=None):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


# Path: stestr/tests/test_selection.py
import io
import re
from unittest import mock
from stestr import selection
from stestr.tests import base

            self.assertRaises(ImportError, selection.filter_tests,
                              ['fake_regex_with_bad_part[The-BAD-part]'],
                              test_list)
            mock_exit.assert_called_once_with(5)


class TestExclusionReader(base.TestCase):

    def test_exclusion_reader(self):
        exclude_list = io.StringIO()
        for i in range(4):
            exclude_list.write('fake_regex_%s\n' % i)
            exclude_list.write('fake_regex_with_note_%s # note\n' % i)
        exclude_list.seek(0)
        with mock.patch('builtins.open',
                        return_value=exclude_list):
            result = selection.exclusion_reader('fake_path')
        self.assertEqual(2 * 4, len(result))
        note_cnt = 0
        # not assuming ordering, mainly just testing the type
        for r in result:
            self.assertEqual(r[2], [])
            if r[1] == 'note':
                note_cnt += 1
            self.assertIn('search', dir(r[0]))  # like a compiled regexp
        self.assertEqual(note_cnt, 4)

    def test_invalid_regex(self):
        exclude_list = io.StringIO()
        exclude_list.write("fake_regex_with_bad_part[The-BAD-part]")

        exclude_list.seek(0)