How to use test_serial_fails method in stestr

Best Python code snippet using stestr_python

test_return_codes.py

Source:test_return_codes.py Github

copy

Full Screen

...130 cmd = 'stestr run --include-list %s' % path131 self.assertRunExit(cmd, 0)132 def test_serial_passing(self):133 self.assertRunExit('stestr run --serial passing', 0)134 def test_serial_fails(self):135 self.assertRunExit('stestr run --serial', 1)136 def test_serial_exclusion_list(self):137 fd, path = tempfile.mkstemp()138 self.addCleanup(os.remove, path)139 with os.fdopen(fd, 'w') as exclusion_list:140 exclusion_list.write('fail')141 cmd = 'stestr run --serial --exclude-list %s' % path142 self.assertRunExit(cmd, 0)143 def test_serial_inclusion_list(self):144 fd, path = tempfile.mkstemp()145 self.addCleanup(os.remove, path)146 with os.fdopen(fd, 'w') as inclusion_list:147 inclusion_list.write('passing')148 cmd = 'stestr run --serial --include-list %s' % path...

Full Screen

Full Screen

test_bisect_return_codes.py

Source:test_bisect_return_codes.py Github

copy

Full Screen

1# Licensed under the Apache License, Version 2.0 (the "License"); you may2# not use this file except in compliance with the License. You may obtain3# a copy of the License at4#5# http://www.apache.org/licenses/LICENSE-2.06#7# Unless required by applicable law or agreed to in writing, software8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the10# License for the specific language governing permissions and limitations11# under the License.12import os13import shutil14import subprocess15import tempfile16from stestr.tests import base17class TestBisectReturnCodes(base.TestCase):18 def setUp(self):19 super().setUp()20 # Setup test dirs21 self.directory = tempfile.mkdtemp(prefix='stestr-unit')22 self.addCleanup(shutil.rmtree, self.directory)23 self.test_dir = os.path.join(self.directory, 'tests')24 os.mkdir(self.test_dir)25 # Setup Test files26 self.testr_conf_file = os.path.join(self.directory, '.stestr.conf')27 self.setup_cfg_file = os.path.join(self.directory, 'setup.cfg')28 self.init_file = os.path.join(self.test_dir, '__init__.py')29 self.setup_py = os.path.join(self.directory, 'setup.py')30 self.user_config = os.path.join(self.directory, 'stestr.yaml')31 shutil.copy('stestr/tests/files/testr-conf', self.testr_conf_file)32 shutil.copy('setup.py', self.setup_py)33 shutil.copy('stestr/tests/files/setup.cfg', self.setup_cfg_file)34 shutil.copy('stestr/tests/files/__init__.py', self.init_file)35 shutil.copy('stestr/tests/files/stestr.yaml', self.user_config)36 # Move around the test code37 self.serial_fail_file = os.path.join(self.test_dir,38 'test_serial_fails.py')39 shutil.copy('stestr/tests/files/bisect-fail-serial-tests',40 self.serial_fail_file)41 # Change directory, run wrapper and check result42 self.addCleanup(os.chdir, os.path.abspath(os.curdir))43 os.chdir(self.directory)44 subprocess.call('stestr init', shell=True)45 def test_bisect_serial_fail_detected(self):46 p = subprocess.Popen(47 "stestr run --serial", shell=True, stdout=subprocess.PIPE,48 stderr=subprocess.PIPE)49 out, err = p.communicate()50 self.assertEqual(1, p.returncode,51 'stestr run returned an unexpected return code'52 'Stdout: %s\nStderr: %s' % (out, err))53 p_analyze = subprocess.Popen(54 "stestr --user-config stestr.yaml run --analyze-isolation",55 shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)56 out, err = p_analyze.communicate()57 out = out.decode('utf-8')58 # For debugging potential failures59 lines = str(out.rstrip()).splitlines()60 self.assertEqual(3, p_analyze.returncode,61 'Analyze isolation returned an unexpected return code'62 '\nStdout: %s\nStderr: %s' % (out, err))63 last_line = ('tests.test_serial_fails.TestFakeClass.test_B '64 'tests.test_serial_fails.TestFakeClass.test_A')...

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