コード例 #1
0
ファイル: output.py プロジェクト: akukday/konira
    def single_exception(self, failure):
        exc        = failure.get('failure')
        name       = failure.get('exc_name')
        trace      = failure.get('trace')
        pretty_exc = PrettyExc(exc, debug=self.config.get('debug'))

        self.failure_header(pretty_exc.exception_description)
        starts = pretty_exc.exception_file_start
        ends   = pretty_exc.exception_file_end

        if starts == ends:
            self.std.writeln("Starts and Ends: ", 'red')
            self.std.println(format_file_line(pretty_exc.exception_file_start, pretty_exc.exception_line_start))
        else:
            self.std.writeln("Starts: ", 'red')
            self.std.println(format_file_line(pretty_exc.exception_file_start, pretty_exc.exception_line_start))
            self.std.writeln("Ends: ", 'red')
            self.std.println(format_file_line(pretty_exc.exception_file_end, pretty_exc.exception_line_end))

        if self.config.get('traceback'):
            if name == 'AssertionError':
                reassert = konira_assert(trace)            
                if reassert:
                    self.assertion_diff(reassert)
                    self.std.writeln(pretty_exc.formatted_exception)
                else:
                    self.std.writeln(pretty_exc.formatted_exception)
            else:
                self.std.writeln(pretty_exc.formatted_exception)
コード例 #2
0
ファイル: case_exc.py プロジェクト: akukday/konira
        except:
            self.bad_trace = inspect.trace()[0]

        try:
            assert ('a',1) == ('b',1)
        except:
            self.tpl_trace = inspect.trace()[0]

        try:
            assert {'a':1} == {'b':1}
        except:
            self.dict_trace = inspect.trace()[0]


    it "is None when the source is invalid":
        reassert = exc.konira_assert(self.trace)
        assert reassert == None


    it "returns a valid diff when comparing strings":
        reassert = exc.konira_assert(self.bad_trace)
        description = ['long string == Long string', '- long string', '? ^', '+ Long string', '? ^']
        assert reassert == description
        
        
    it "returns valid dictionary comparisons":
        reassert = exc.konira_assert(self.dict_trace)
        description = ["{'a': 1} == {'b': 1}", "- {'a': 1}", '?   ^', "+ {'b': 1}", '?   ^']
        assert reassert == description