How to use _pretty_print method in hypothesis

Best Python code snippet using hypothesis

mcli.py

Source: mcli.py Github

copy

Full Screen

...27 '__init__.py')):28 sys.path.insert(0, possible_topdir)29from troveclient.compat import common30oparser = None31def _pretty_print(info):32 print(json.dumps(info, sort_keys=True, indent=4))33class HostCommands(common.AuthedCommandsBase):34 """Commands to list info on hosts."""35 params = [36 'name',37 ]38 def update_all(self):39 """Update all instances on a host."""40 self._require('name')41 self.dbaas.hosts.update_all(self.name)42 def get(self):43 """List details for the specified host."""44 self._require('name')45 self._pretty_print(self.dbaas.hosts.get, self.name)46 def list(self):47 """List all compute hosts."""48 self._pretty_list(self.dbaas.hosts.index)49class QuotaCommands(common.AuthedCommandsBase):50 """List and update quota limits for a tenant."""51 params = ['id',52 'instances',53 'volumes',54 'backups']55 def list(self):56 """List all quotas for a tenant."""57 self._require('id')58 self._pretty_print(self.dbaas.quota.show, self.id)59 def update(self):60 """Update quota limits for a tenant."""61 self._require('id')62 self._pretty_print(self.dbaas.quota.update, self.id,63 dict((param, getattr(self, param))64 for param in self.params if param != 'id'))65class RootCommands(common.AuthedCommandsBase):66 """List details about the root info for an instance."""67 params = [68 'id',69 ]70 def history(self):71 """List root history for the instance."""72 self._require('id')73 self._pretty_print(self.dbaas.management.root_enabled_history, self.id)74class AccountCommands(common.AuthedCommandsBase):75 """Commands to list account info."""76 params = [77 'id',78 ]79 def list(self):80 """List all accounts with non-deleted instances."""81 self._pretty_print(self.dbaas.accounts.index)82 def get(self):83 """List details for the account provided."""84 self._require('id')85 self._pretty_print(self.dbaas.accounts.show, self.id)86class InstanceCommands(common.AuthedCommandsBase):87 """List details about an instance."""88 params = [89 'deleted',90 'id',91 'limit',92 'marker',93 'host',94 ]95 def get(self):96 """List details for the instance."""97 self._require('id')98 self._pretty_print(self.dbaas.management.show, self.id)99 def list(self):100 """List all instances for account."""101 deleted = None102 if self.deleted is not None:103 if self.deleted.lower() in ['true']:104 deleted = True105 elif self.deleted.lower() in ['false']:106 deleted = False107 self._pretty_paged(self.dbaas.management.index, deleted=deleted)108 def hwinfo(self):109 """Show hardware information details about an instance."""110 self._require('id')111 self._pretty_print(self.dbaas.hwinfo.get, self.id)112 def diagnostic(self):113 """List diagnostic details about an instance."""114 self._require('id')115 self._pretty_print(self.dbaas.diagnostics.get, self.id)116 def stop(self):117 """Stop MySQL on the given instance."""118 self._require('id')119 self._pretty_print(self.dbaas.management.stop, self.id)120 def reboot(self):121 """Reboot the instance."""122 self._require('id')123 self._pretty_print(self.dbaas.management.reboot, self.id)124 def migrate(self):125 """Migrate the instance."""126 self._require('id')127 self._pretty_print(self.dbaas.management.migrate, self.id, self.host)128 def reset_task_status(self):129 """Set the instance's task status to NONE."""130 self._require('id')131 self._pretty_print(self.dbaas.management.reset_task_status, self.id)132class StorageCommands(common.AuthedCommandsBase):133 """Commands to list devices info."""134 params = []135 def list(self):136 """List details for the storage device."""137 self._pretty_list(self.dbaas.storage.index)138class FlavorsCommands(common.AuthedCommandsBase):139 """Commands for managing Flavors."""140 params = [141 'name',142 'ram',143 'disk',144 'vcpus',145 'flavor_id',146 'ephemeral',147 'swap',148 'rxtx_factor',149 'service_type'150 ]151 def create(self):152 """Create a new flavor."""153 self._require('name', 'ram', 'disk', 'vcpus',154 'flavor_id', 'service_type')155 self._pretty_print(self.dbaas.mgmt_flavor.create, self.name,156 self.ram, self.disk, self.vcpus, self.flavor_id,157 self.ephemeral, self.swap, self.rxtx_factor,158 self.service_type)159def config_options(oparser):160 oparser.add_option("-u", "--url", default="http:/​/​localhost:5000/​v1.1",161 help="Auth API endpoint URL with port and version. \162 Default: http:/​/​localhost:5000/​v1.1")163COMMANDS = {164 'account': AccountCommands,165 'host': HostCommands,166 'instance': InstanceCommands,167 'root': RootCommands,168 'storage': StorageCommands,169 'quota': QuotaCommands,...

Full Screen

Full Screen

redis-faina.py

Source: redis-faina.py Github

copy

Full Screen

...97 self._record_key(entry['key'])98 def _top_n(self, stat, n=8):99 sorted_items = sorted(stat.iteritems(), key = lambda x: x[1], reverse = True)100 return sorted_items[:n]101 def _pretty_print(self, result, title, percentages=False):102 print title103 print '=' * 40104 if not result:105 print 'n/​a\n'106 return107 max_key_len = max((len(x[0]) for x in result))108 max_val_len = max((len(str(x[1])) for x in result))109 for key, val in result:110 key_padding = max(max_key_len - len(key), 0) * ' '111 if percentages:112 val_padding = max(max_val_len - len(str(val)), 0) * ' '113 val = '%s%s\t(%.2f%%)' % (val, val_padding, (float(val) /​ self.line_count) * 100)114 print key,key_padding,'\t',val115 print116 def print_stats(self):117 self._pretty_print(self._general_stats(), 'Overall Stats')118 self._pretty_print(self._top_n(self.prefixes), 'Top Prefixes', percentages = True)119 self._pretty_print(self._top_n(self.keys), 'Top Keys', percentages = True)120 self._pretty_print(self._top_n(self.commands), 'Top Commands', percentages = True)121 self._pretty_print(self._time_stats(self.times), 'Command Time (microsecs)')122 self._pretty_print(self._heaviest_commands(self.times), 'Heaviest Commands (microsecs)')123 self._pretty_print(self._slowest_commands(self.times), 'Slowest Calls')124 def process_input(self, input):125 for line in input:126 self.line_count += 1127 line = line.strip()128 match = self.line_re.match(line)129 if not match:130 if line != "OK":131 self.skipped_lines += 1132 continue133 self.process_entry(match.groupdict())134if __name__ == '__main__':135 parser = argparse.ArgumentParser()136 parser.add_argument(137 'input',...

Full Screen

Full Screen

analyzer.py

Source: analyzer.py Github

copy

Full Screen

...3from pandas import DataFrame4logger = logging.getLogger(__name__)5class Analyzer(object):6 """Analyzer for transformed data"""7 def _pretty_print(self, data_frame, title=''):8 """Pretty print DataFrame to console9 :param data_frame: DataFrame to print10 :param title: title to print before printing DataFrame11 """12 print('\n')13 print(title)14 print(tabulate(data_frame, headers='keys', tablefmt='fancy_grid'))15 def analyze(self, storage, top_n=10):16 """Output statistics based on transformed data17 :param storage: storage to read data for analyzing18 :param top_n: number of top results19 """20 result_df = storage.read_data(orient='records')21 # Output vacancies count22 print()23 count_stats = result_df.shape[0]24 print('Vacancies count')25 print(count_stats)26 # Output vacancies period27 date_stats = DataFrame(result_df['created_at'].aggregate(['min', 'max'])).astype(str)28 self._pretty_print(date_stats, 'Vacancies period')29 # Output vacancies by cities30 city_stats = DataFrame(result_df['area.name'].value_counts()[:top_n])31 self._pretty_print(city_stats, 'Top cities with vacancies')32 # Output key skills information from nested json structure33 key_skills_df = storage.read_data(normalize=True, record_path='key_skills')34 key_skills_stats = DataFrame(key_skills_df['name'].str.lower().value_counts().head(top_n))35 self._pretty_print(key_skills_stats, 'Top key skills for vacancies')36 # Output schedule information37 schedule_stats = DataFrame(result_df['schedule.name'].value_counts())38 self._pretty_print(schedule_stats, 'Schedule distribution')39 # Output experience information40 experience_stats = DataFrame(result_df['experience.name'].value_counts())41 self._pretty_print(experience_stats, 'Required experience distribution')42 # Output employer information43 employer_stats = DataFrame(result_df['employer.name'].value_counts().head(top_n))44 self._pretty_print(employer_stats, 'Top companies with vacancies')45 # Output specializations information form nested json structure46 spec_df = storage.read_data(normalize=True, record_path='specializations')47 spec_stats = DataFrame(spec_df['name'].value_counts().head(top_n))48 self._pretty_print(spec_stats, 'Top specializations with vacancies')49 # Output salaries stats regardless of whether salary is net or gross50 # due to different tax rates in different countries51 salary_stats = result_df.aggregate({'salary.from.rur': ['min', 'max', 'mean', 'std'],52 'salary.to.rur': ['min', 'max', 'mean', 'std']})...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Joomla Testing Guide: How To Test Joomla Websites

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.

Now Log Bugs Using LambdaTest and DevRev

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.

Why Agile Teams Have to Understand How to Analyze and Make adjustments

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.

27 Best Website Testing Tools In 2022

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.

11 Best Mobile Automation Testing Tools In 2022

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.

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