How to use _check_get_run_command method in stestr

Best Python code snippet using stestr_python

test_config_file.py

Source:test_config_file.py Github

copy

Full Screen

...23 @mock.patch.object(config_file.util, 'get_repo_open')24 @mock.patch.object(config_file.test_processor, 'TestProcessorFixture')25 @mock.patch.object(config_file, 'sys')26 @mock.patch('os.path.exists', new=lambda x: True)27 def _check_get_run_command(self, mock_sys, mock_TestProcessorFixture,28 mock_get_repo_open, platform='win32',29 group_regex='.*', parallel_class=False,30 sys_executable='/usr/bin/python',31 expected_python='/usr/bin/python',32 expected_group_callback=mock.ANY,33 environment=None):34 mock_sys.platform = platform35 mock_sys.executable = sys_executable36 if environment is None:37 environment = {'PYTHON': ''}38 with mock.patch.dict('os.environ', environment):39 fixture = \40 self._testr_conf.get_run_command(test_path='fake_test_path',41 top_dir='fake_top_dir',42 group_regex=group_regex,43 parallel_class=parallel_class)44 self.assertEqual(mock_TestProcessorFixture.return_value, fixture)45 mock_get_repo_open.assert_called_once_with(repo_url=None)46 command = '"%s" -m stestr.subunit_runner.run discover -t "%s" "%s" ' \47 '$LISTOPT $IDOPTION' % (expected_python, 'fake_top_dir',48 'fake_test_path')49 # Ensure TestProcessorFixture is created with defaults except for where50 # we specfied and with the correct python.51 mock_TestProcessorFixture.assert_called_once_with(52 None, command, "--list", "--load-list $IDFILE",53 mock_get_repo_open.return_value,54 exclude_regex=None,55 exclude_list=None, concurrency=0,56 group_callback=expected_group_callback,57 test_filters=None, randomize=False, serial=False,58 include_list=None, worker_path=None)59 @mock.patch.object(config_file, 'sys')60 def _check_get_run_command_exception(self, mock_sys, platform='win32',61 sys_executable='/usr/bin/python',62 environment=None):63 mock_sys.platform = platform64 mock_sys.executable = sys_executable65 if environment is None:66 environment = {'PYTHON': ''}67 with mock.patch.dict('os.environ', environment):68 self.assertRaises(RuntimeError, self._testr_conf.get_run_command,69 test_path='fake_test_path',70 top_dir='fake_top_dir')71 def test_get_run_command_linux(self):72 self._check_get_run_command(73 platform='linux2',74 expected_python='/usr/bin/python')75 def test_get_run_command_emptysysexecutable_noenv(self):76 self._check_get_run_command_exception(77 platform='linux2',78 sys_executable=None)79 def test_get_run_command_emptysysexecutable_win32(self):80 self._check_get_run_command_exception(81 platform='win32', sys_executable=None,82 environment={'PYTHON': 'python3'})83 def test_get_run_command_emptysysexecutable_withenv(self):84 self._check_get_run_command(85 platform='linux2', sys_executable=None,86 expected_python='${PYTHON}',87 environment={'PYTHON': '/usr/bin/python3'})88 def test_get_run_command_win32(self):89 self._check_get_run_command()90 def test_get_run_command_parallel_class(self):91 self._check_get_run_command(parallel_class=True)92 def test_get_run_command_nogroup_regex_noparallel_class(self):93 self._testr_conf.parser.has_option.return_value = False94 self._check_get_run_command(group_regex='',95 expected_group_callback=None)96 @ddt.data(('.\\', '.\\\\'),97 ('a\\b\\', 'a\\b\\\\'),98 ('a\\b', 'a\\b'))99 @ddt.unpack100 @mock.patch('os.sep', new='\\')101 def test_sanitize_dir_win32(self, path, expected):102 sanitized = self._testr_conf._sanitize_path(path)...

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