Best Python code snippet using pandera_python
test.py
Source: test.py
1import random2import sys3import time4import pytest5try:6 import user as user_code7except ImportError:8 pass9# пÑедполагаем, ÑÑо вÑвод полÑзоваÑÐµÐ»Ñ output не нÑжен - пÑовеÑÑем ÑолÑко дeкоÑаÑоÑÑ10class MsgError: # вÑвод ÑообÑÐµÐ½Ð¸Ñ Ð² завиÑимоÑÑи Ð¾Ñ Ñипа оÑибки11 def __init__(self, method_name, *args, **kwargs):12 self.result = getattr(self, method_name)(*args, **kwargs)13 def method_exist(self, method_name):14 return f'ÐÑовеÑÑÑе не Ñдален ли декоÑаÑÐ¾Ñ `{method_name} в иÑÑ
одном коде`'15 def method_correct(self, method_name):16 return f'ÐÑовеÑÑÑе коÑÑекÑноÑÑÑ ÑабоÑÑ Ð¼ÐµÑода `{method_name}`'17 def is_cached(self, method_name):18 return f'ÐÑовеÑÑÑе, ÑÑо декоÑаÑÐ¾Ñ `{method_name}()` кÑÑиÑÑÐµÑ Ð´Ð°Ð½Ð½Ñе пÑи вÑзове'19@pytest.fixture20def msg_err():21 def _msg_err(msg_name, *args, **kwargs):22 msg = MsgError(msg_name, *args, **kwargs)23 return msg.result24 return _msg_err25@pytest.fixture26def input_time_cache():27 data = []28 n1 = random.randint(1, 2)/1029 data.append(n1)30 data.append(random.randint(3, 4)/10)31 data.append(n1)32 return data33@pytest.fixture34def output_time_cache(input_time_cache):35 return input_time_cache[:len(input_time_cache)-1]+[0.0]36class TestFunc:37 time_args = [(0.3,), (0.1,)]38 def test_has_method_time_check(self, msg_err):39 assert hasattr(user_code, 'time_check'), msg_err('method_exist', 'time_check')40 @pytest.mark.parametrize("args", time_args)41 def test_time_check(self, args, msg_err):42 original_stdout = sys.stdout43 with open('time_check_output.txt', 'w', encoding="utf-8") as f:44 sys.stdout = f45 measured_sleep = user_code.time_check(time.sleep)46 measured_sleep(args[0])47 sys.stdout = original_stdout48 with open('time_check_output.txt', 'r', encoding="utf-8") as f:49 decorated_output = f.read()50 assert (f'ÐÑÐµÐ¼Ñ Ð²ÑÐ¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ ÑÑнкÑии: {round(float(args[0]),1)} Ñ.'51 in decorated_output), msg_err('method_correct', 'time_check')52 def test_has_method_cache_args(self, msg_err):53 assert hasattr(user_code, 'cache_args'), msg_err('method_exist', 'cache_args')54 def test_cache_args(self, input_time_cache, output_time_cache, msg_err):55 original_stdout = sys.stdout56 with open('cache_check_output.txt', 'w', encoding="utf-8") as f:57 sys.stdout = f58 cached_sleep = user_code.time_check(user_code.cache_args(time.sleep))59 for time_par in input_time_cache:60 cached_sleep(time_par)61 sys.stdout = original_stdout62 with open('cache_check_output.txt', 'r', encoding="utf-8") as f:63 cached_output = f.read()64 row_list = cached_output.split('\n')65 for i, time_par in enumerate(output_time_cache):66 assert (f'ÐÑÐµÐ¼Ñ Ð²ÑÐ¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ ÑÑнкÑии: {round(float(time_par),1)} Ñ.' in67 row_list[i]), msg_err('method_correct', 'cache_args')68 assert (f'ÐÑÐµÐ¼Ñ Ð²ÑÐ¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ ÑÑнкÑии: {round(float(input_time_cache[2]),1)} Ñ.'...
dataframe_schema.py
Source: dataframe_schema.py
...63 def peakmem_check_input(self):64 @check_input(self.in_schema)65 def transform_first_arg(self):66 return Decorators.transformer(self.df)67 def time_check_output(self):68 @check_output(self.out_schema)69 def transform_first_arg(self):70 return Decorators.transformer(self.df)71 def mem_check_output(self):72 @check_output(self.out_schema)73 def transform_first_arg(self):74 return Decorators.transformer(self.df)75 def peakmem_check_output(self):76 @check_output(self.out_schema)77 def transform_first_arg(self):...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
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!!