How to use test_run_time method in stestr

Best Python code snippet using stestr_python

test_results.py

Source:test_results.py Github

copy

Full Screen

1# Copyright (C) 2010 Google Inc. All rights reserved.2#3# Redistribution and use in source and binary forms, with or without4# modification, are permitted provided that the following conditions are5# met:6#7# * Redistributions of source code must retain the above copyright8# notice, this list of conditions and the following disclaimer.9# * Redistributions in binary form must reproduce the above10# copyright notice, this list of conditions and the following disclaimer11# in the documentation and/or other materials provided with the12# distribution.13# * Neither the name of Google Inc. nor the names of its14# contributors may be used to endorse or promote products derived from15# this software without specific prior written permission.16#17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28import cPickle29import test_failures30class TestResult(object):31 """Data object containing the results of a single test."""32 @staticmethod33 def loads(str):34 return cPickle.loads(str)35 def __init__(self, filename, failures=None, test_run_time=None):36 # FIXME: s/filename/name to be consistent with the rest of layout_package.37 self.filename = filename38 self.failures = failures or []39 self.test_run_time = test_run_time or 040 # FIXME: Setting this in the constructor makes this class hard to mutate.41 self.type = test_failures.determine_result_type(failures)42 def __eq__(self, other):43 return (self.filename == other.filename and44 self.failures == other.failures and45 self.test_run_time == other.test_run_time)46 def __ne__(self, other):47 return not (self == other)48 def has_failure_matching_types(self, types):49 for failure in self.failures:50 if type(failure) in types:51 return True52 return False53 def dumps(self):...

Full Screen

Full Screen

__main__.py

Source:__main__.py Github

copy

Full Screen

...34 result = module.func(arr_unsorted.copy())35 is_correct = result == arr_sorted36 print(f"Test correct with {n} elements for \"{module.name}\": {is_correct}")37 assert is_correct, f"The sorting function of \"{module.name}\" returned incorrect result"38def test_run_time(n):39 arr = [random.randint(-1000000, +1000000) for i in range(n)]40 for module in modules:41 if hasattr(module, 'limit') and n > module.limit:42 print(f"{n}: {module.name}: skip")43 else:44 copy = arr.copy()45 time = timeit.timeit(lambda: module.func(copy), number=1)46 print(f"{n}: {module.name}: {time}")47test_correct(25_000)48test_correct(100_000)49# Super casual test of the growth of time with the growth of instance50test_run_time(25_000)51test_run_time(50_000)52test_run_time(100_000)53test_run_time(200_000)54test_run_time(400_000)55test_run_time(800_000)...

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