def blue(self, text): self._restoreColor() if platform.system() == 'Windows': # pragma: no cover # Default blue in windows is unreadable (such awful defaults...) return termstyle.cyan(text) else: return termstyle.blue(text)
def _summarize(self): """summarize all tests - the number of failures, errors and successes""" self._line(termstyle.black) self._out("%s test%s run in %0.1f seconds" % ( self.total, self._plural(self.total), time.time() - self.start_time)) if self.total > self.success: self._outln(". ") additionals = [] if self.failure > 0: additionals.append(termstyle.red("%s FAILED" % ( self.failure,))) if self.error > 0: additionals.append(termstyle.yellow("%s error%s" % ( self.error, self._plural(self.error) ))) if self.skip > 0: additionals.append(termstyle.blue("%s skipped" % ( self.skip))) self._out(', '.join(additionals)) self._out(termstyle.green(" (%s test%s passed)" % ( self.success, self._plural(self.success) ))) self._outln()
def report(self): print('*************************') print("Amount:\t%s" % blue(self.amount)) if self.cost < 0.0: print("Cost:\t%s" % red(self.cost)) elif self.cost > 0.0: print("Cost:\t%s" % green(self.cost)) else: print("Cost:\t%s" % blue(self.cost)) print("Hold:\t%s" % blue(self.holdings)) if self.gain < 0.0: print("Gain: \t%s" % red(self.gain)) elif self.gain > 0.0: print("Gain: \t%s" % green(self.gain)) else: print("Gain: \t%s" % blue(self.gain))
def _loop(self): q = raw_input(blue("\nfind/open file: ")) if len(q) == 0: q = 1 # open the first found file by default try: index = int(q) except ValueError: index = None if index is not None: self.open(index) else: self.finder.find(Search(q)) search = self.finder.results() self.summarise(search.results, search.text)
def _file_line(self, tb): """formats the file / lineno / function line of a traceback element""" prefix = "file://" prefix = "" f = tb.tb_frame if '__unittest' in f.f_globals: # this is the magical flag that prevents unittest internal # code from junking up the stacktrace return None filename = f.f_code.co_filename lineno = tb.tb_lineno linecache.checkcache(filename) function_name = f.f_code.co_name line_contents = linecache.getline(filename, lineno, f.f_globals).strip() return " %s line %s in %s\n %s" % ( termstyle.blue(prefix, self._relative_path(filename)), lineno, termstyle.cyan(function_name), line_contents)
def _format_traceback_line(self, tb): """ Formats the file / lineno / function line of a traceback element. Returns None is the line is not relevent to the user i.e. inside the test runner. """ if self._is_relevant_tb_level(tb): return None f = tb.tb_frame filename = f.f_code.co_filename lineno = tb.tb_lineno linecache.checkcache(filename) function_name = f.f_code.co_name line_contents = linecache.getline(filename, lineno, f.f_globals).strip() return " %s line %s in %s\n %s" % ( termstyle.blue(self._relative_path(filename) if self.use_relative_path else filename), termstyle.bold(termstyle.cyan(lineno)), termstyle.cyan(function_name), line_contents )
def _file_line(self, tb): """formats the file / lineno / function line of a traceback element""" prefix = "file://" prefix = "" f = tb.tb_frame if '__unittest' in f.f_globals: # this is the magical flag that prevents unittest internal # code from junking up the stacktrace return None filename = f.f_code.co_filename lineno = tb.tb_lineno linecache.checkcache(filename) function_name = f.f_code.co_name line_contents = linecache.getline(filename, lineno, f.f_globals).strip() return " %s line %s in %s\n %s" % ( termstyle.blue(prefix, self._relative_path(filename)), termstyle.bold(termstyle.cyan(lineno)), termstyle.cyan(function_name), line_contents)
def blue(self, text): self._restoreColor() if self.html: return '<span style="color: rgb(0,128,255)">{}</span>'.format(text) else: return termstyle.blue(text)
def test_translates_sequences_of_styles_single_callable(self): scheme = ColourScheme(dict(blue_italic=('blue', 'italic'))) scheme.blue_italic('{*}') | should | be_equal_to( termstyle.italic(termstyle.blue('{*}')))
def response_IDLE(self, tag, rest): print termstyle.blue('%s - DEBUG response_IDLE' % datetime.now()) print termstyle.blue('\ttag- %s' % tag) print termstyle.blue('\trest - %s' % rest) return tag, rest
def test_translates_sequences_of_styles_single_callable(self): scheme = ColourScheme(dict(blue_italic=('blue', 'italic'))) scheme.blue_italic('{*}') |should| be_equal_to( termstyle.italic(termstyle.blue('{*}')))