Add isatty method to LazyWriter.

This commit is contained in:
Eric Shull 2012-11-08 13:36:33 -05:00 committed by benoitc
parent 044732f7bc
commit e58f8b59b7
2 changed files with 16 additions and 0 deletions

View File

@ -87,6 +87,9 @@ class LazyWriter(object):
def flush(self):
self.open().flush()
def isatty(self):
return bool(self.fileobj and self.fileobj.isatty())
class SafeAtoms(dict):
def __init__(self, atoms):

View File

@ -0,0 +1,13 @@
import sys
from gunicorn.glogging import LazyWriter
def test_lazywriter_isatty():
orig = sys.stdout
sys.stdout = LazyWriter('test.log')
try:
sys.stdout.isatty()
except AttributeError:
raise AssertionError("LazyWriter has no attribute 'isatty'")
sys.stdout = orig