Best Python code snippet using localstack_python
test_jsx_tag.py
Source: test_jsx_tag.py
...20 .replace('>', '>').replace('"', '"').replace(''', "'")21class SetNestedTest(TestCase):22 def test_simple_key(self):23 d = {}24 set_nested(d, 'foo', 3)25 self.assertEqual({'foo': 3}, d)26 def test_one_level(self):27 d = {}28 set_nested(d, 'foo.bar', 3)29 self.assertEqual({'foo': {'bar': 3}}, d)30 def test_two_levels(self):31 d = {}32 set_nested(d, 'foo.bar.baz', 3)33 self.assertEqual({'foo': {'bar': {'baz': 3}}}, d)34 def test_with_existing_stuff(self):35 d = {'one': 1, 'foo': {'baz': 2}}36 set_nested(d, 'foo.bar', 3)37 self.assertEqual({'one': 1, 'foo': {'bar': 3, 'baz': 2}}, d)38 def test_with_existing_object(self):39 """40 If a top level item to be serialized is an object, we shouldn't fail at41 trying to set the lower level item.42 """43 d = {'foo': object()}44 set_nested(d, 'foo.bar', 3)45 self.assertEqual({'foo': {'bar': 3}}, d)46 def test_top_level_item_doesnt_clobber_nested(self):47 # foo.bar has previously been set48 d = {'foo': {'bar': 3}}49 # if we later try to set foo, we shouldn't clobber foo.bar50 set_nested(d, 'foo', object())51 self.assertEqual({'foo': {'bar': 3}}, d)52class JsxTagTest(TestCase):53 def test_loading_tags(self):54 # We can `load` the tag library55 engine = Engine.get_default()56 template_object = engine.from_string("{% load jsx %}")57 result = template_object.render(Context({}))58 self.assertEqual("", result)59 def try_it(self, content, expected_ctx, raw=False, context=None):60 # Assert that if we do a {% jsx %} block with the given content, that we61 # get the standard empty script tag in the output, the data-sha1 attribute62 # has the sha1 digest of the content, and the `data-ctx` is63 # a JSON-encoding of `expected_ctx`.64 # If `raw` is True, use `content` as the entire template content, not just...
properties_tester.py
Source: properties_tester.py
1# Copyright 2004-2008 Roman Yakovenko.2# Distributed under the Boost Software License, Version 1.0. (See3# accompanying file LICENSE_1_0.txt or copy at4# http://www.boost.org/LICENSE_1_0.txt)5import os6import sys7import unittest8import fundamental_tester_base9from pyplusplus.module_builder import call_policies10class tester_t(fundamental_tester_base.fundamental_tester_base_t):11 EXTENSION_NAME = 'properties'12 def __init__( self, *args ):13 fundamental_tester_base.fundamental_tester_base_t.__init__(14 self15 , tester_t.EXTENSION_NAME16 , *args )17 def customize(self, mb ):18 cls = mb.class_( 'properties_tester_t' )19 count = cls.member_function( 'count' )20 set_count = cls.member_function( 'set_count' )21 count.exclude()22 set_count.exclude()23 cls.add_property( "count", count, set_count )24 cls.add_property( "count_ro", count )25 get_nested = cls.member_function( 'get_nested' )26 get_nested.call_policies = call_policies.return_internal_reference()27 set_nested = cls.member_function( 'set_nested' )28 cls.add_property( "nested_", get_nested, set_nested )29 cls.add_property( "nested_ro", get_nested )30 cls = mb.class_( 'properties_finder_tester_t' )31 cls.add_properties( exclude_accessors=True )32 self.assertTrue( 6 == len( cls.properties ) )33 self.assertTrue( cls.name in [pr.name for pr in cls.properties] )34 def run_tests(self, module):35 pt = module.properties_tester_t()36 self.assertTrue( pt.count == 0 )37 pt.count = 2138 self.assertTrue( pt.m_count == 21 )39def create_suite():40 suite = unittest.TestSuite()41 suite.addTest( unittest.makeSuite(tester_t))42 return suite43def run_suite():44 unittest.TextTestRunner(verbosity=2).run( create_suite() )45if __name__ == "__main__":...
cache.py
Source: cache.py
1# -*- coding: utf-8 -*-2def set_nested(data, value, *keys):3 """Assign to a nested dictionary.4 :param dict data: Dictionary to mutate5 :param value: Value to set6 :param list *keys: List of nested keys7 >>> data = {}8 >>> set_nested(data, 'hi', 'k0', 'k1', 'k2')9 >>> data10 {'k0': {'k1': {'k2': 'hi'}}}11 """12 if len(keys) == 1:13 data[keys[0]] = value14 else:15 if keys[0] not in data:16 data[keys[0]] = {}17 set_nested(data[keys[0]], value, *keys[1:])18class Cache(object):19 """Simple container for storing cached data.20 """21 def __init__(self):22 self.data = {}23 @property24 def raw(self):25 return self.data26 def set(self, schema, key, value):27 set_nested(self.data, value, schema, key)28 def get(self, schema, key):29 try:30 return self.data[schema][key]31 except KeyError:32 return None33 def pop(self, schema, key):34 self.data[schema].pop(key, None)35 def clear(self):36 self.__init__()37 def clear_schema(self, schema):38 self.data.pop(schema, None)39 def __nonzero__(self):40 return bool(self.data)41 # Python 3...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!