Best Python code snippet using avocado_python
test_criteria.py
Source: test_criteria.py
...90 self.assertEqual(criteria_2.fields, criteria_1.fields)91class TestValidateFilters(unittest.TestCase):92 def test_as_dict(self):93 input = {'id': 'repo1'}94 ret = criteria._validate_filters(input)95 self.assertEqual(ret, input)96 def test_as_string(self):97 self.assertRaises(exceptions.InvalidValue, criteria._validate_filters, 'abc 123')98 def test_as_int(self):99 self.assertRaises(exceptions.InvalidValue, criteria._validate_filters, 123)100 def test_as_none(self):101 ret = criteria._validate_filters(None)102 self.assertTrue(ret is None)103 def test_as_bool(self):104 self.assertRaises(exceptions.InvalidValue, criteria._validate_filters, True)105 def test_as_list(self):106 self.assertRaises(exceptions.InvalidValue, criteria._validate_filters, [])107class TestValidateSort(unittest.TestCase):108 def test_as_list(self):109 input = []110 ret = criteria._validate_sort(input)111 self.assertEqual(ret, input)112 def test_as_tuple(self):113 input = ()114 ret = criteria._validate_sort(input)115 self.assertEqual(ret, [])...
sales_register_with_employee.py
Source: sales_register_with_employee.py
...9def execute(filters=None):10 filters.net_amount_col_idx = 1811 return extend_report(sales_register, filters)12def extend_report(base_execute, filters):13 _validate_filters(filters)14 columns, data = base_execute(filters)15 inv_idx = next(x for x, v in enumerate(columns) if "Invoice" in v)16 emp_idx = len(columns)17 return (18 _extend_columns(filters, columns),19 _extend_data(filters, data, inv_idx, emp_idx),20 )21def _validate_filters(filters):22 if not 0 <= frappe.utils.flt(filters.commission_rate) <= 100:23 frappe.throw(frappe._("Commission Rate should be between 0 and 100%"))24def _extend_columns(filters, columns):25 return (26 columns27 + ["Sales Employee:Link/Employee:120", "Sales Employee Name::150"]28 + [29 "{}% Commission on Net Sales:Currency:120".format(30 frappe.utils.flt(filters.commission_rate)31 )32 ]33 )34def _extend_data(filters, data, inv_idx, emp_idx):35 invoices = [x[inv_idx] for x in data]...
functools.py
Source: functools.py
...4from itertools import chain5from namedlist import namedtuple, NO_DEFAULT6from six import iteritems, iterkeys7from .api import kv_format_pairs8def _validate_filters(fields, filters):9 for field in iterkeys(filters):10 if field in fields:11 continue12 raise TypeError(("extra filter for unexpected filter '{0}'"13 .format(field)))14 return filters.copy()15class KvFormatter(object):16 """Predefine a list of fields with optional default values and filters.17 The resulting object allows to reuse the field names for formatting18 purpose when called.19 """20 def __init__(self, field_names, default=NO_DEFAULT, filters=None):21 self.args_tuple = namedtuple('_ArgsTuple', field_names, default)22 self.fields = self.args_tuple._fields23 self.filters = (_validate_filters(self.fields, filters)24 if filters else {})25 def pairs(self, *args, **kwargs):26 items = dict((k, self.filters.get(k, lambda a: a)(v))27 for k, v in chain(zip(self.fields, args),28 iteritems(kwargs)))29 return zip(self.fields, self.args_tuple(**items))30 def __call__(self, *args, **kwargs):...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
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.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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!!