Best Python code snippet using localstack_python
test_dist.py
Source: test_dist.py
...60 "long_description": "Long\ndescription",61 "description": "Short description",62 "keywords": ["one", "two"]63 }64 def merge_dicts(d1, d2):65 d1 = d1.copy()66 d1.update(d2)67 return d168 test_cases = [69 ('Metadata version 1.0', base_attrs.copy()),70 ('Metadata version 1.1: Provides', merge_dicts(base_attrs, {71 'provides': ['package']72 })),73 ('Metadata version 1.1: Obsoletes', merge_dicts(base_attrs, {74 'obsoletes': ['foo']75 })),76 ('Metadata version 1.1: Classifiers', merge_dicts(base_attrs, {77 'classifiers': [78 'Programming Language :: Python :: 3',79 'Programming Language :: Python :: 3.7',80 'License :: OSI Approved :: MIT License',81 ]})),82 ('Metadata version 1.1: Download URL', merge_dicts(base_attrs, {83 'download_url': 'https://example.com'84 })),85 ('Metadata Version 1.2: Requires-Python', merge_dicts(base_attrs, {86 'python_requires': '>=3.7'87 })),88 pytest.param(89 'Metadata Version 1.2: Project-Url',90 merge_dicts(base_attrs, {91 'project_urls': {92 'Foo': 'https://example.bar'93 }94 }), marks=pytest.mark.xfail(95 reason="Issue #1578: project_urls not read"96 )),97 ('Metadata Version 2.1: Long Description Content Type',98 merge_dicts(base_attrs, {99 'long_description_content_type': 'text/x-rst; charset=UTF-8'100 })),101 pytest.param(102 'Metadata Version 2.1: Provides Extra',103 merge_dicts(base_attrs, {104 'provides_extras': ['foo', 'bar']105 }), marks=pytest.mark.xfail(reason="provides_extras not read")),106 ('Missing author, missing author e-mail',107 {'name': 'foo', 'version': '1.0.0'}),108 ('Missing author',109 {'name': 'foo',110 'version': '1.0.0',111 'author_email': 'snorri@sturluson.name'}),112 ('Missing author e-mail',113 {'name': 'foo',114 'version': '1.0.0',115 'author': 'Snorri Sturluson'}),116 ('Missing author',117 {'name': 'foo',118 'version': '1.0.0',119 'author': 'Snorri Sturluson'}),120 ]121 return test_cases122@pytest.mark.parametrize('name,attrs', __read_test_cases())123def test_read_metadata(name, attrs):124 dist = Distribution(attrs)125 metadata_out = dist.metadata126 dist_class = metadata_out.__class__127 # Write to PKG_INFO and then load into a new metadata object128 if six.PY2:129 PKG_INFO = io.BytesIO()130 else:131 PKG_INFO = io.StringIO()132 metadata_out.write_pkg_file(PKG_INFO)133 PKG_INFO.seek(0)134 metadata_in = dist_class()135 metadata_in.read_pkg_file(PKG_INFO)136 tested_attrs = [137 ('name', dist_class.get_name),138 ('version', dist_class.get_version),139 ('author', dist_class.get_contact),140 ('author_email', dist_class.get_contact_email),141 ('metadata_version', dist_class.get_metadata_version),142 ('provides', dist_class.get_provides),143 ('description', dist_class.get_description),144 ('download_url', dist_class.get_download_url),145 ('keywords', dist_class.get_keywords),146 ('platforms', dist_class.get_platforms),147 ('obsoletes', dist_class.get_obsoletes),148 ('requires', dist_class.get_requires),149 ('classifiers', dist_class.get_classifiers),150 ('project_urls', lambda s: getattr(s, 'project_urls', {})),151 ('provides_extras', lambda s: getattr(s, 'provides_extras', set())),152 ]153 for attr, getter in tested_attrs:154 assert getter(metadata_in) == getter(metadata_out)155def __maintainer_test_cases():156 attrs = {"name": "package",157 "version": "1.0",158 "description": "xxx"}159 def merge_dicts(d1, d2):160 d1 = d1.copy()161 d1.update(d2)162 return d1163 test_cases = [164 ('No author, no maintainer', attrs.copy()),165 ('Author (no e-mail), no maintainer', merge_dicts(166 attrs,167 {'author': 'Author Name'})),168 ('Author (e-mail), no maintainer', merge_dicts(169 attrs,170 {'author': 'Author Name',171 'author_email': 'author@name.com'})),172 ('No author, maintainer (no e-mail)', merge_dicts(173 attrs,174 {'maintainer': 'Maintainer Name'})),175 ('No author, maintainer (e-mail)', merge_dicts(176 attrs,177 {'maintainer': 'Maintainer Name',178 'maintainer_email': 'maintainer@name.com'})),179 ('Author (no e-mail), Maintainer (no-email)', merge_dicts(180 attrs,181 {'author': 'Author Name',182 'maintainer': 'Maintainer Name'})),183 ('Author (e-mail), Maintainer (e-mail)', merge_dicts(184 attrs,185 {'author': 'Author Name',186 'author_email': 'author@name.com',187 'maintainer': 'Maintainer Name',188 'maintainer_email': 'maintainer@name.com'})),189 ('No author (e-mail), no maintainer (e-mail)', merge_dicts(190 attrs,191 {'author_email': 'author@name.com',192 'maintainer_email': 'maintainer@name.com'})),193 ('Author unicode', merge_dicts(194 attrs,195 {'author': 'éæ²¢å¯'})),196 ('Maintainer unicode', merge_dicts(197 attrs,198 {'maintainer': 'Jan Åukasiewicz'})),199 ]200 return test_cases201@pytest.mark.parametrize('name,attrs', __maintainer_test_cases())202def test_maintainer_author(name, attrs, tmpdir):203 tested_keys = {204 'author': 'Author',205 'author_email': 'Author-email',206 'maintainer': 'Maintainer',207 'maintainer_email': 'Maintainer-email',208 }209 # Generate a PKG-INFO file210 dist = Distribution(attrs)...
test_merge.py
Source: test_merge.py
1from pino.utils import merge_dicts2def test_merge_does_not_mutate():3 a = {"a": "a", "aa": "aa"}4 b = {"b": "b", "bb": "bb"}5 assert merge_dicts(a,b) == {"a": "a", "aa": "aa", "b": "b", "bb": "bb"}6 assert a == {"a": "a", "aa": "aa"}7 assert b == {"b": "b", "bb": "bb"}8def test_simple_merge():9 a = {"a": "a", "aa": "aa"}10 b = {"b": "b", "bb": "bb"}11 assert merge_dicts(a,b) == {"a": "a", "aa": "aa", "b": "b", "bb": "bb"}12def test_simple_merge_with_overwrite():13 a = {"key": "a"}14 b = {"key": "b"}15 assert merge_dicts(a, b) == {"key": "a"}16def test_complex_merge():17 a = {"a": "a", "common": {"a": "a"}}18 b = {"b": "b", "common": {"b": "b"}}19 assert merge_dicts(a,b) == {"a": "a", "b": "b", "common": {"a": "a", "b": "b"}}20def test_complex_merge_with_overwrite():21 a = {"a": "a", "common": {"a": "a", "key": "a"}}22 b = {"b": "b", "common": {"b": "b", "key": "b"}}23 assert merge_dicts(a,b) == {"a": "a", "b": "b", "common": {"a": "a", "b": "b", "key": "a"}}24def test_no_a_or_no_b():25 anyobj = {"b": "b", "common": {"b": "b", "key": "b"}}26 assert merge_dicts(None, anyobj) == anyobj27 assert merge_dicts({}, anyobj) == anyobj28 assert merge_dicts(anyobj, None) == anyobj...
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!!