How to use report_debug_info method in hypothesis

Best Python code snippet using hypothesis

lektor_i18n.py

Source:lektor_i18n.py Github

copy

Full Screen

...81 self.translations = collections.OrderedDict()82 def add(self, text, source):83 if not text in self.translations.keys():84 self.translations[text]=[]85 reporter.report_debug_info('added to translation memory : ', truncate(text))86 if not source in self.translations[text]:87 self.translations[text].append(source)88 def __repr__(self):89 return PrettyPrinter(2).pformat(self.translations)90 def as_pot(self, content_language):91 """returns a POT version of the translation dictionnary"""92 now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')93 now += '+%s'%(time.tzname[0])94 result = POT_HEADER % {'LANGUAGE' : content_language, 'NOW' : now}95 for msg, paths in self.translations.items():96 result += "#: %s\n"%" ".join(paths)97 for token, repl in {'\n': '\\n', '\t': '\\t', '"': '\\"'}.items():98 msg = msg.replace(token, repl)99 result+='msgid "%s"\n' % msg100 result+='msgstr ""\n\n'101 return result102 def write_pot(self, pot_filename, language):103 if not os.path.exists(os.path.dirname(pot_filename)):104 os.makedirs(os.path.dirname(pot_filename))105 with open(pot_filename,'w') as f:106 f.write(encode(self.as_pot(language)))107 def merge_pot(self, from_filenames, to_filename):108 msgcat=locate_executable('msgcat')109 cmdline=[msgcat, "--use-first"]110 cmdline.extend(from_filenames)111 cmdline.extend(("-o", to_filename))112 reporter.report_debug_info('msgcat cmd line', cmdline)113 portable_popen(cmdline).wait()114 def parse_templates(self, to_filename):115 pybabel=locate_executable('pybabel')116 cmdline=[pybabel, 'extract', '-F', 'babel.cfg', "-o", to_filename, "./"]117 reporter.report_debug_info('pybabel cmd line', cmdline)118 portable_popen(cmdline).wait()119translations = Translations() # let's have a singleton120class POFile():121 FILENAME_PATTERN = "contents+%s.po"122 def __init__(self, language, i18npath):123 self.language=language124 self.i18npath=i18npath125 def _exists(self):126 """Returns True if <language>.po file exists in i18npath"""127 filename=self.FILENAME_PATTERN%self.language128 return exists( join(self.i18npath, filename) )129 def _msg_init(self):130 """Generates the first <language>.po file"""131 msginit=locate_executable('msginit')132 cmdline=[msginit, "-i", "contents.pot", "-l", self.language, "-o", self.FILENAME_PATTERN%self.language, "--no-translator"]133 reporter.report_debug_info('msginit cmd line', cmdline)134 portable_popen(cmdline, cwd=self.i18npath).wait()135 def _msg_merge(self):136 """Merges an existing <language>.po file with .pot file"""137 msgmerge=locate_executable('msgmerge')138 cmdline=[msgmerge, self.FILENAME_PATTERN%self.language, "contents.pot", "-U", "-N", "--backup=simple"]139 reporter.report_debug_info('msgmerge cmd line', cmdline)140 portable_popen(cmdline, cwd=self.i18npath).wait()141 def _prepare_locale_dir(self):142 """Prepares the i18n/<language>/LC_MESSAGES/ to store the .mo file ; returns the dirname"""143 directory = join('_compiled',self.language, "LC_MESSAGES")144 try:145 os.makedirs(join(self.i18npath, directory))146 except OSError:147 pass # already exists, no big deal148 return directory149 def _msg_fmt(self, locale_dirname):150 """Compile an existing <language>.po file into a .mo file"""151 msgfmt=locate_executable('msgfmt')152 cmdline=[msgfmt, self.FILENAME_PATTERN%self.language, "-o", join(locale_dirname,"contents.mo")]153 reporter.report_debug_info('msgfmt cmd line', cmdline)154 portable_popen(cmdline, cwd=self.i18npath).wait()155 def generate(self):156 if self._exists():157 self._msg_merge()158 else:159 self._msg_init()160 locale_dirname=self._prepare_locale_dir()161 self._msg_fmt(locale_dirname)162def line_starts_new_block(line, prev_line):163 """Detect a new block in a lektor document. Blocks are delimited by a line164 containing 3 or more dashes. This actually matches the definition of a165 markdown level 2 heading, so this function returns False if no colon was166 found in the line before, so if it isn't a new block with a key: value pair167 before."""...

Full Screen

Full Screen

reporter.py

Source:reporter.py Github

copy

Full Screen

...88 def report_build_all_failure(self, failures):89 pass90 def report_dependencies(self, dependencies):91 for dep in dependencies:92 self.report_debug_info('dependency', dep[1])93 def report_dirty_flag(self, value):94 pass95 def report_write_source_info(self, info):96 pass97 def report_prune_source_info(self, source):98 pass99 def report_sub_artifact(self, artifact):100 pass101 def report_build_func(self, build_func):102 pass103 def report_debug_info(self, key, value):104 pass105 def report_generic(self, message):106 pass107 def report_pruned_artifact(self, artifact_name):108 pass109 @contextmanager110 def process_source(self, source):111 now = time.time()112 self.source_stack.append(source)113 self.enter_source()114 try:115 yield116 finally:117 self.source_stack.pop()118 self.leave_source(now)119 def enter_source(self):120 pass121 def leave_source(self, start_time):122 pass123class NullReporter(Reporter):124 pass125class CliReporter(Reporter):126 def __init__(self, env, verbosity=0):127 Reporter.__init__(self, env, verbosity)128 self.indentation = 0129 def indent(self):130 self.indentation += 1131 def outdent(self):132 self.indentation -= 1133 def _write_line(self, text):134 click.echo(' ' * (self.indentation * 2) + text)135 def _write_kv_info(self, key, value):136 self._write_line('%s: %s' % (key, style(unicode(value), fg='yellow')))137 def start_build(self, activity):138 self._write_line(style('Started %s' % activity, fg='cyan'))139 if not self.show_build_info:140 return141 self._write_line(style(' Tree: %s' % self.env.root_path, fg='cyan'))142 self._write_line(style(' Output path: %s' %143 self.builder.destination_path, fg='cyan'))144 def finish_build(self, activity, start_time):145 self._write_line(style('Finished %s in %.2f sec' % (146 activity, time.time() - start_time), fg='cyan'))147 def start_artifact_build(self, is_current):148 artifact = self.current_artifact149 if is_current:150 if not self.show_current_artifacts:151 return152 sign = click.style('X', fg='cyan')153 else:154 sign = click.style('U', fg='green')155 self._write_line('%s %s' % (sign, artifact.artifact_name))156 self.indent()157 def finish_artifact_build(self, start_time):158 self.outdent()159 def report_build_all_failure(self, failures):160 self._write_line(click.style(161 'Error: Build failed with %s failure%s.' % (162 failures, failures != 1 and 's' or ''), fg='red'))163 def report_failure(self, artifact, exc_info):164 sign = click.style('E', fg='red')165 err = ' '.join(''.join(traceback.format_exception_only(166 *exc_info[:2])).splitlines()).strip()167 self._write_line('%s %s (%s)' % (168 sign, artifact.artifact_name, err))169 def report_dirty_flag(self, value):170 if self.show_artifact_internals and (value or self.show_debug_info):171 self._write_kv_info('forcing sources dirty', value)172 def report_write_source_info(self, info):173 if self.show_artifact_internals and self.show_debug_info:174 self._write_kv_info('writing source info', '%s [%s]' % (175 info.title_i18n['en'], info.type))176 def report_prune_source_info(self, source):177 if self.show_artifact_internals and self.show_debug_info:178 self._write_kv_info('pruning source info', source)179 def report_build_func(self, build_func):180 if self.show_artifact_internals:181 self._write_kv_info('build program',182 describe_build_func(build_func))183 def report_sub_artifact(self, artifact):184 if self.show_artifact_internals:185 self._write_kv_info('sub artifact', artifact.artifact_name)186 def report_debug_info(self, key, value):187 if self.show_debug_info:188 self._write_kv_info(key, value)189 def report_generic(self, message):190 self._write_line(style(unicode(message), fg='cyan'))191 def enter_source(self):192 if not self.show_source_internals:193 return194 self._write_line('Source %s' % style(repr(195 self.current_source), fg='magenta'))196 self.indent()197 def leave_source(self, start_time):198 if self.show_source_internals:199 self.outdent()200 def report_pruned_artifact(self, artifact_name):...

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