How to use test_quiet method in tox

Best Python code snippet using tox_python

test_setup.py

Source:test_setup.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3"""4 PyTest command class5 setup.py files in each package should include a cmdclass mapping6 from "test" to PyTest.7 Copyright 2007-2013 Glencoe Software, Inc. All rights reserved.8 Use is subject to license terms supplied in LICENSE.txt9"""10import os11import sys12from setuptools.command.test import test as TestCommand13LIB = os.path.join("..", "..", "tests", "python")14sys.path.insert(0, LIB)15class PyTest(TestCommand):16 user_options = [17 ('test-path=', 't', "base dir for test collection"),18 ('test-pythonpath=', 'p', "prepend 'pythonpath' to PYTHONPATH"),19 ('test-ice-config=', 'i',20 "use specified 'ice config' file instead of default"),21 ('test-string=', 'k', "only run tests including 'string'"),22 ('test-marker=', 'm', "only run tests including 'marker'"),23 ('test-no-capture', 's', "don't suppress test output"),24 ('test-failfast', 'x', "Exit on first error"),25 ('test-verbose', 'v', "more verbose output"),26 ('test-quiet', 'q', "less verbose output"),27 ('junitxml=', None, "create junit-xml style report file at 'path'"),28 ('pdb', None, "fallback to pdb on error"),29 ('markers', None, "list available markers'"),30 ]31 def initialize_options(self):32 TestCommand.initialize_options(self)33 self.test_pythonpath = None34 self.test_ice_config = None35 self.test_string = None36 self.test_marker = None37 self.test_path = None38 self.test_no_capture = False39 self.test_failfast = False40 self.test_quiet = False41 self.test_verbose = False42 self.junitxml = None43 self.pdb = False44 self.markers = False45 def finalize_options(self):46 TestCommand.finalize_options(self)47 if self.test_path is None:48 self.test_path = 'test'49 self.test_args = [self.test_path]50 if self.test_string is not None:51 self.test_args.extend(['-k', self.test_string])52 if self.test_marker is not None:53 self.test_args.extend(['-m', self.test_marker])54 if self.test_no_capture:55 self.test_args.extend(['-s'])56 if self.test_failfast:57 self.test_args.extend(['-x'])58 if self.test_verbose:59 self.test_args.extend(['-v'])60 if self.test_quiet:61 self.test_args.extend(['-q'])62 if self.junitxml is not None:63 self.test_args.extend(['--junitxml', self.junitxml])64 if self.pdb:65 self.test_args.extend(['--pdb'])66 print self.test_failfast67 self.test_suite = True68 if self.markers:69 self.test_args = "--markers"70 if self.test_ice_config is None:71 self.test_ice_config = os.path.abspath('ice.config')72 if 'ICE_CONFIG' not in os.environ:73 os.environ['ICE_CONFIG'] = self.test_ice_config74 def run_tests(self):75 if self.test_pythonpath is not None:76 sys.path.insert(0, self.test_pythonpath)77 # import here, cause outside the eggs aren't loaded78 import pytest79 errno = pytest.main(self.test_args)...

Full Screen

Full Screen

test_process.py

Source:test_process.py Github

copy

Full Screen

...9 process = Process()10 rc, lines = process.popen('echo "Hello world"')11 self.assertEqual(rc, 0)12 self.assertEqual(lines, ['Hello world'])13 def test_quiet(self):14 process = Process(quiet=True)15 rc, lines = process.popen('echo "Hello world"')16 self.assertEqual(rc, 0)17 self.assertEqual(lines, ['Hello world'])18 def test_env(self):19 env = os.environ.copy()20 env['HELLO'] = 'Hello world'21 process = Process(quiet=True, env=env)22 rc, lines = process.popen('echo ${HELLO}')23 self.assertEqual(rc, 0)24 self.assertEqual(lines, ['Hello world'])25 def test_echo(self):26 process = Process()27 rc, lines = process.popen('echo "Hello world"', echo=False)28 self.assertEqual(rc, 0)29 self.assertEqual(lines, ['Hello world'])30 def test_echo2(self):31 process = Process()32 rc, lines = process.popen('$ "Hello world"', echo2=False)33 self.assertEqual(rc, 127)34 self.assertEqual(lines, [])35 @quiet36 def test_bad_cmd(self):37 process = Process()38 rc, lines = process.popen('$ "Hello world"')39 self.assertEqual(rc, 127)40 self.assertEqual(lines, [])41class PipeTests(unittest.TestCase):42 def test_simple(self):43 process = Process()44 value = process.pipe('echo "Hello world"')45 self.assertEqual(value, 'Hello world')46 def test_quiet(self):47 process = Process(quiet=True)48 value = process.pipe('echo "Hello world"')49 self.assertEqual(value, 'Hello world')50 def test_env(self):51 env = os.environ.copy()52 env['HELLO'] = 'Hello world'53 process = Process(quiet=True, env=env)54 value = process.pipe('echo ${HELLO}')55 self.assertEqual(value, 'Hello world')56 @quiet57 def test_bad_cmd(self):58 process = Process()59 value = process.pipe('$ "Hello world"')60 self.assertEqual(value, '')61class SystemTests(JailSetup):62 def test_simple(self):63 process = Process()64 rc = process.system('echo "Hello world" > output')65 self.assertEqual(rc, 0)66 self.assertEqual(process.pipe('cat output'), 'Hello world')67 def test_quiet(self):68 process = Process(quiet=True)69 rc = process.system('echo "Hello world"')70 self.assertEqual(rc, 0)71 def test_env(self):72 env = os.environ.copy()73 env['HELLO'] = 'Hello world'74 process = Process(env=env)75 rc = process.system('echo ${HELLO} > output')76 self.assertEqual(rc, 0)77 self.assertEqual(process.pipe('cat output'), 'Hello world')78 def test_bad_cmd(self):79 process = Process()80 rc = process.system('$ "Hello world" 2> output')81 self.assertEqual(rc, 127)

Full Screen

Full Screen

test_tox_logging.py

Source:test_tox_logging.py Github

copy

Full Screen

...15 at.start_logging(fname)16 at.logger.info("test4")17 at.start_logging(fname, reset=True)18 at.logger.info("test5")19def test_quiet():20 # Nothing should be printed out by this test21 logger_level = at.logger.getEffectiveLevel()22 with at.Quiet():23 at.demo("sir")24 with at.Quiet(False):25 at.demo("sir")26 assert at.logger.getEffectiveLevel() == logger_level, "Logger level has been permanently changed"27if __name__ == "__main__":28 test_quiet()...

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 tox 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