mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-19 03:51:07 +00:00
Python3: fix logging
This commit is contained in:
parent
75626d456a
commit
45d95289ab
1 changed files with 9 additions and 3 deletions
|
|
@ -20,7 +20,13 @@ Test decorators.
|
|||
|
||||
import unittest
|
||||
import time
|
||||
from io import BytesIO
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from io import StringIO
|
||||
|
||||
import linkcheck.decorators
|
||||
|
||||
|
||||
|
|
@ -36,10 +42,10 @@ class TestDecorators (unittest.TestCase):
|
|||
self.assertEqual(f(), 42)
|
||||
|
||||
def test_timeit2 (self):
|
||||
log = BytesIO()
|
||||
log = StringIO()
|
||||
@linkcheck.decorators.timed(log=log, limit=0)
|
||||
def f ():
|
||||
time.sleep(1)
|
||||
return 42
|
||||
self.assertEqual(f(), 42)
|
||||
self.assertTrue(log.getvalue())
|
||||
self.assertEqual(log.getvalue(), 'f took 1.00 seconds\n()\n{}\n')
|
||||
|
|
|
|||
Loading…
Reference in a new issue