Skip to content
Browse files

Fix FileReporter to expect a tuple to be returned from Formatter.form…

…at_text()
  • Loading branch information...
1 parent 97924dd commit 8842e98b1756589f3388085070fc1d67ec055dbb @skrul skrul committed Jun 24, 2011
Showing with 35 additions and 1 deletion.
  1. +34 −0 tests/test_reporter.py
  2. +1 −1 weberror/reporter.py
View
34 tests/test_reporter.py
@@ -44,3 +44,37 @@ def test_logger():
assert len(content.splitlines()) == 8
assert 'ZeroDivisionError' in content
+def test_file():
+ fn = setup_file('test_file.log')
+ f = open(fn, 'w')
+ rep = FileReporter(
+ file=f,
+ show_hidden_frames=False)
+
+ try:
+ int('a')
+ except:
+ exc_data = collector.collect_exception(*sys.exc_info())
+ else:
+ assert 0
+ rep.report(exc_data)
+ f.flush()
+ content = open(fn).read()
+ assert len(content.splitlines()) == 4
+ assert 'ValueError' in content
+ assert 'int' in content
+ assert 'test_reporter.py' in content
+ assert 'test_file' in content
+
+ try:
+ 1 / 0
+ except:
+ exc_data = collector.collect_exception(*sys.exc_info())
+ else:
+ assert 0
+ rep.report(exc_data)
+ f.flush()
+ content = open(fn).read()
+ print content
+ assert len(content.splitlines()) == 8
+ assert 'ZeroDivisionError' in content
View
2 weberror/reporter.py
@@ -123,7 +123,7 @@ def check_params(self):
"You must give a file object")
def report(self, exc_data):
- text = self.format_text(
+ text, head_text = self.format_text(
exc_data, show_hidden_frames=self.show_hidden_frames)
self.file.write(text + '\n' + '-'*60 + '\n')

0 comments on commit 8842e98

Please sign in to comment.
Something went wrong with that request. Please try again.