Best Python code snippet using pytest-benchmark
__init__.py
Source:__init__.py
1# Copyright (C) 2009, 2011 Canonical Ltd2# 3# This program is free software: you can redistribute it and/or modify4# it under the terms of the GNU General Public License version 3 as5# published by the Free Software Foundation.6# 7# This program is distributed in the hope that it will be useful, but8# WITHOUT ANY WARRANTY; without even the implied warranty of9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10# General Public License for more details.11# 12# You should have received a copy of the GNU General Public License13# along with this program. If not, see <http://www.gnu.org/licenses/>.14"""Helpers for loading and running the test suite."""15import unittest16TestCase = unittest.TestCase17def run_suite(verbose=False):18 if verbose:19 verbosity = 220 else:21 verbosity = 122 runner = unittest.TextTestRunner(verbosity=verbosity)23 suite = test_suite()24 result = runner.run(suite)25 return result.wasSuccessful()26def test_suite():27 module_names = [28 'test__intset',29 'test__loader',30 'test__scanner',31 'test_loader',32 'test_perf_counter',33 'test_scanner',34 ]35 full_names = [__name__ + '.' + n for n in module_names]36 loader = unittest.TestLoader()37 suite = loader.suiteClass()38 for full_name in full_names:39 module = __import__(full_name, {}, {}, [None])40 suite.addTests(loader.loadTestsFromModule(module))...
test_time.py
Source:test_time.py
...6# ----------------------------------------------------------------------7# Python modules8import time9from time import perf_counter10def test_perf_counter():11 DELTA = 1.012 t0 = perf_counter()13 time.sleep(DELTA)14 t1 = perf_counter()15 assert t1 - t0 >= DELTA16def test_perf_counter_implementation():...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!