How to use merge_dicts method in molecule

Best Python code snippet using molecule_python

test_dist.py

Source: test_dist.py Github

copy

Full Screen

...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)...

Full Screen

Full Screen

test_merge.py

Source: test_merge.py Github

copy

Full Screen

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...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

LIVE With Automation Testing For OTT Streaming Devices ????

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.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

Two-phase Model-based Testing

Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.

Stop Losing Money. Invest in Software Testing

I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.

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 molecule 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