Best Python code snippet using hypothesis
ant_design_aside.py
Source: ant_design_aside.py
1# -*- coding: utf-8 -*-2from random import Random3import scrapy4from urllib import parse as urlparse5from scrapy.http import Request6from ScrapyDemo.items import (7 AntdAsideNavItem, AntdComponentDetailItem, CustomItemLoader)8random_ins = Random()9class AntDesignAsideSpider(scrapy.Spider):10 name = 'ant_design_aside'11 allowed_domains = ['ant.design']12 start_urls = ['https://ant.design/docs/react/introduce-cn']13 def parse(self, response):14 post_nodes = response.css('#Components\$Menu .ant-menu-item-group')15 for post_node in post_nodes:16 primary_title = post_node.css(17 '.ant-menu-item-group-title::text').extract_first('')18 secondary_nodes = post_node.css(19 '.ant-menu-item-group-list>.ant-menu-item')20 for secondary_node in secondary_nodes:21 secondary_key = secondary_node.css(22 'a::attr(href)').extract_first('')23 secondary_name = secondary_node.css(24 'a>span:first-child::text').extract_first('')25 secondary_title = secondary_node.css(26 'span.chinese::text').extract_first('')27 yield Request(28 url=urlparse.urljoin(response.url, secondary_key),29 meta={30 'primary_title': primary_title,31 'secondary_title': secondary_title,32 'secondary_name': secondary_name,33 'secondary_key': secondary_key34 },35 callback=self.parse_block36 )37 def parse_block(self, response):38 primary_title = response.meta.get('primary_title', '')39 secondary_title = response.meta.get('secondary_title', '')40 secondary_name = response.meta.get('secondary_name', '')41 secondary_key = response.meta.get('secondary_key', '')42 post_nodes = response.css('#demo-toc>li')43 for post_node in post_nodes:44 # aside_nav_item = AntdAsideNavItem()45 # item_loader = CustomItemLoader(46 # item=aside_nav_item,47 # selector=post_node48 # )49 # item_loader.add_value('primary_title', primary_title)50 # item_loader.add_value('secondary_title', secondary_title)51 # item_loader.add_value('secondary_name', secondary_name)52 # item_loader.add_value('secondary_key', secondary_key)53 # aside_nav_item = item_loader.load_item()54 # yield aside_nav_item55 detail_id = post_node.css('a::attr(href)').extract_first('')56 name = post_node.css('a::text').extract_first('')57 if not detail_id:58 return59 css_str = detail_id + '>.code-box-meta>.code-box-description'60 detail_block = response.css(css_str)61 component_detail_item = AntdComponentDetailItem()62 component_loader = CustomItemLoader(63 item=component_detail_item,64 selector=post_node65 )66 component_loader.add_value('name', name)67 component_loader.add_value(68 'easy_to_use', random_ins.randint(1, 99))69 component_loader.add_value('key', detail_id.replace('#', '', 1))70 component_loader.add_value('category_name', secondary_name)71 least_title = detail_block.css(' div *::text').extract()72 component_loader.add_value(73 'desc', ''.join([str(i) for i in least_title]))74 component_detail_item = component_loader.load_item()...
6654_symmetric_key.py
Source: 6654_symmetric_key.py
1# --------------------------------------------------------------------------------------------2# Copyright (c) Microsoft Corporation. All rights reserved.3# Licensed under the MIT License. See License.txt in the project root for license information.4# --------------------------------------------------------------------------------------------5# pylint: skip-file6# coding=utf-87# --------------------------------------------------------------------------8# Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.09# Changes may cause incorrect behavior and will be lost if the code is10# regenerated.11# --------------------------------------------------------------------------12from msrest.serialization import Model13class SymmetricKey(Model):14 """Symmetric keys to access device.15 :param primary_key: The primary key.16 :type primary_key: str17 :param secondary_key: The secondary key.18 :type secondary_key: str19 """20 _attribute_map = {21 'primary_key': {'key': 'primaryKey', 'type': 'str'},22 'secondary_key': {'key': 'secondaryKey', 'type': 'str'},23 }24 def __init__(self, primary_key=None, secondary_key=None):25 self.primary_key = primary_key...
metro_creds.py
Source: metro_creds.py
1import pickle , base64, sys2from getpass import getpass3def main():4 if sys.version_info < (3,0):5 primary_key = getpass("primary_key: ")6 primary_key = base64.b64encode(primary_key)7 secondary_key = getpass("secondary_key: ")8 secondary_key = base64.b64encode(secondary_key)9 else:10 primary_key = getpass("primary_key: ")11 primary_key = base64.b64encode(primary_key.encode())12 secondary_key = getpass("secondary_key: ")13 secondary_key = base64.b64encode(secondary_key.encode())14 with open("metro_creds.bin", 'wb') as writefile:15 creds = (primary_key, secondary_key)16 pickle.dump(creds, writefile)17if __name__ == "__main__":...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.
Mobile application development is on the rise like never before, and it proportionally invites the need to perform thorough testing with the right mobile testing strategies. The strategies majorly involve the usage of various mobile automation testing tools. Mobile testing tools help businesses automate their application testing and cut down the extra cost, time, and chances of human error.
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!!