How to use parse_bool method in Behave

Best Python code snippet using behave

test_utils.py

Source:test_utils.py Github

copy

Full Screen

...198 assert(result['path'] is None)199 assert(result['query'] is None)200 assert(result['url'] == 'http://nuxref.com')201 assert(result['qsd'] == {})202def test_parse_bool():203 "utils: parse_bool() testing """204 assert(utils.parse_bool('Enabled', None) is True)205 assert(utils.parse_bool('Disabled', None) is False)206 assert(utils.parse_bool('Allow', None) is True)207 assert(utils.parse_bool('Deny', None) is False)208 assert(utils.parse_bool('Yes', None) is True)209 assert(utils.parse_bool('YES', None) is True)210 assert(utils.parse_bool('Always', None) is True)211 assert(utils.parse_bool('No', None) is False)212 assert(utils.parse_bool('NO', None) is False)213 assert(utils.parse_bool('NEVER', None) is False)214 assert(utils.parse_bool('TrUE', None) is True)215 assert(utils.parse_bool('tRUe', None) is True)216 assert(utils.parse_bool('FAlse', None) is False)217 assert(utils.parse_bool('F', None) is False)218 assert(utils.parse_bool('T', None) is True)219 assert(utils.parse_bool('0', None) is False)220 assert(utils.parse_bool('1', None) is True)221 assert(utils.parse_bool('True', None) is True)222 assert(utils.parse_bool('Yes', None) is True)223 assert(utils.parse_bool(1, None) is True)224 assert(utils.parse_bool(0, None) is False)225 assert(utils.parse_bool(True, None) is True)226 assert(utils.parse_bool(False, None) is False)227 # only the int of 0 will return False since the function228 # casts this to a boolean229 assert(utils.parse_bool(2, None) is True)230 # An empty list is still false231 assert(utils.parse_bool([], None) is False)232 # But a list that contains something is True233 assert(utils.parse_bool(['value', ], None) is True)234 # Use Default (which is False)235 assert(utils.parse_bool('OhYeah') is False)236 # Adjust Default and get a different result237 assert(utils.parse_bool('OhYeah', True) is True)238def test_is_hostname():239 """240 API: is_hostname() function241 """242 # Valid Hostnames243 assert utils.is_hostname('yahoo.ca') is True244 assert utils.is_hostname('yahoo.ca.') is True245 assert utils.is_hostname('valid-dashes-in-host.ca') is True246 assert utils.is_hostname('valid-underscores_in_host.ca') is True247 # Invalid Hostnames248 assert utils.is_hostname('invalid-characters_#^.ca') is False249 assert utils.is_hostname(' spaces ') is False250 assert utils.is_hostname(' ') is False251 assert utils.is_hostname('') is False...

Full Screen

Full Screen

test_streamable.py

Source:test_streamable.py Github

copy

Full Screen

...159 @streamable160 class A(Streamable):161 pass162 assert A.from_bytes(bytes(A())) == A()163 def test_parse_bool(self):164 assert not parse_bool(io.BytesIO(b"\x00"))165 assert parse_bool(io.BytesIO(b"\x01"))166 # EOF167 with raises(AssertionError):168 parse_bool(io.BytesIO(b""))169 with raises(ValueError):170 parse_bool(io.BytesIO(b"\xff"))171 with raises(ValueError):172 parse_bool(io.BytesIO(b"\x02"))173 def test_parse_optional(self):174 assert parse_optional(io.BytesIO(b"\x00"), parse_bool) is None175 assert parse_optional(io.BytesIO(b"\x01\x01"), parse_bool)176 assert not parse_optional(io.BytesIO(b"\x01\x00"), parse_bool)177 # EOF178 with raises(AssertionError):179 parse_optional(io.BytesIO(b"\x01"), parse_bool)180 # optional must be 0 or 1181 with raises(ValueError):182 parse_optional(io.BytesIO(b"\x02\x00"), parse_bool)183 with raises(ValueError):184 parse_optional(io.BytesIO(b"\xff\x00"), parse_bool)185 def test_parse_bytes(self):186 assert parse_bytes(io.BytesIO(b"\x00\x00\x00\x00")) == b""...

Full Screen

Full Screen

raw_obj.py

Source:raw_obj.py Github

copy

Full Screen

...86 "event_user_groups_historical": parse_str_array(event_user_groups_historical),87 "event_user_groups": parse_str_array(event_user_groups),88 "event_user_is_bot_by_historical": parse_str_array(event_user_is_bot_by_historical),89 "event_user_is_bot_by": parse_str_array(event_user_is_bot_by),90 "event_user_is_created_by_self": parse_bool(event_user_is_created_by_self),91 "event_user_is_created_by_system": parse_bool(event_user_is_created_by_system),92 "event_user_is_created_by_peer": parse_bool(event_user_is_created_by_peer),93 "event_user_is_anonymous": parse_bool(event_user_is_anonymous),94 "event_user_registration_timestamp": parse_date(event_user_registration_timestamp),95 "event_user_creation_timestamp": parse_date(event_user_creation_timestamp),96 "event_user_first_edit_timestamp": parse_date(event_user_first_edit_timestamp),97 "event_user_revision_count": parse_int(event_user_revision_count),98 "event_user_seconds_since_previous_revision": parse_int(event_user_seconds_since_previous_revision),99 "page_id": parse_int(page_id),100 "page_title_historical": parse_str(page_title_historical),101 "page_title": parse_str(page_title),102 "page_namespace_historical": parse_int(page_namespace_historical),103 "page_namespace_is_content_historical": parse_bool(page_namespace_is_content_historical),104 "page_namespace": parse_int(page_namespace),105 "page_namespace_is_content": parse_bool(page_namespace_is_content),106 "page_is_redirect": parse_bool(page_is_redirect),107 "page_is_deleted": parse_bool(page_is_deleted),108 "page_creation_timestamp": parse_date(page_creation_timestamp),109 "page_first_edit_timestamp": parse_date(page_first_edit_timestamp),110 "page_revision_count": parse_int(page_revision_count),111 "page_seconds_since_previous_revision": parse_int(page_seconds_since_previous_revision),112 "user_id": parse_int(user_id),113 "user_text_historical": parse_str(user_text_historical),114 "user_text": parse_str(user_text),115 "user_blocks_historical": parse_str_array(user_blocks_historical),116 "user_blocks": parse_str_array(user_blocks),117 "user_groups_historical": parse_str_array(user_groups_historical),118 "user_groups": parse_str_array(user_groups),119 "user_is_bot_by_historical": parse_str_array(user_is_bot_by_historical),120 "user_is_bot_by": parse_str_array(user_is_bot_by),121 "user_is_created_by_self": parse_bool(user_is_created_by_self),122 "user_is_created_by_system": parse_bool(user_is_created_by_system),123 "user_is_created_by_peer": parse_bool(user_is_created_by_peer),124 "user_is_anonymous": parse_bool(user_is_anonymous),125 "user_registration_timestamp": parse_date(user_registration_timestamp),126 "user_creation_timestamp": parse_date(user_creation_timestamp),127 "user_first_edit_timestamp": parse_date(user_first_edit_timestamp),128 "revision_id": parse_int(revision_id),129 "revision_parent_id": parse_int(revision_parent_id),130 "revision_minor_edit": parse_bool(revision_minor_edit),131 "revision_deleted_parts": parse_str_array(revision_deleted_parts),132 "revision_deleted_parts_are_suppressed": parse_bool(revision_deleted_parts_are_suppressed),133 "revision_text_bytes": parse_int(revision_text_bytes),134 "revision_text_bytes_diff": parse_int(revision_text_bytes_diff),135 "revision_text_sha1": parse_str(revision_text_sha1),136 "revision_content_model": parse_str(revision_content_model),137 "revision_content_format": parse_str(revision_content_format),138 "revision_is_deleted_by_page_deletion": parse_bool(revision_is_deleted_by_page_deletion),139 "revision_deleted_by_page_deletion_timestamp": parse_str(revision_deleted_by_page_deletion_timestamp),140 "revision_is_identity_reverted": parse_bool(revision_is_identity_reverted),141 "revision_first_identity_reverting_revision_id": parse_int(revision_first_identity_reverting_revision_id),142 "revision_seconds_to_identity_revert": parse_int(revision_seconds_to_identity_revert),143 "revision_is_identity_revert": parse_bool(revision_is_identity_revert),144 "revision_is_from_before_page_creation": parse_bool(revision_is_from_before_page_creation),145 "revision_tags": parse_str_array(revision_tags)...

Full Screen

Full Screen

test_config.py

Source:test_config.py Github

copy

Full Screen

...30def test_config_bool_parse():31 """32 Tests boolean parsing function33 """34 assert UltraSyncConfig.parse_bool(True) is True35 assert UltraSyncConfig.parse_bool(1) is True36 assert UltraSyncConfig.parse_bool('Yes') is True37 assert UltraSyncConfig.parse_bool('Y') is True38 assert UltraSyncConfig.parse_bool('True') is True39 assert UltraSyncConfig.parse_bool('T') is True40 assert UltraSyncConfig.parse_bool('Enable') is True41 assert UltraSyncConfig.parse_bool('E') is True42 assert UltraSyncConfig.parse_bool('+') is True43 assert UltraSyncConfig.parse_bool(False) is False44 assert UltraSyncConfig.parse_bool(0) is False45 assert UltraSyncConfig.parse_bool('No') is False46 assert UltraSyncConfig.parse_bool('N') is False47 assert UltraSyncConfig.parse_bool('False') is False48 assert UltraSyncConfig.parse_bool('F') is False49 assert UltraSyncConfig.parse_bool('Disable') is False50 assert UltraSyncConfig.parse_bool('Deny') is False51 assert UltraSyncConfig.parse_bool('D') is False52 assert UltraSyncConfig.parse_bool('-') is False53 # Test defaults from bad inputs54 assert UltraSyncConfig.parse_bool('%', True) is True55 assert UltraSyncConfig.parse_bool('!', False) is False56def test_config_file(tmpdir):57 """58 Test a configuration file59 """60 # We can't load invalid files61 with pytest.raises(AttributeError):62 UltraSyncConfig(path='invalid-file')63 # Create a config file64 t = tmpdir.join("config")65 content = [66 'host: ultrasync.example.com',67 'pin: 1234',68 'user: Admin',69 ]...

Full Screen

Full Screen

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