check print output in test_save_and_restore
This commit is contained in:
@@ -139,7 +139,7 @@ class TestHypercornLogHndl:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass # don't call the suoer(.__init__ for unit tests
|
pass # don't call the suoer(.__init__ for unit tests
|
||||||
|
|
||||||
def test_save_and_restore(self):
|
def test_save_and_restore(self, capsys):
|
||||||
s = self.FakeServer()
|
s = self.FakeServer()
|
||||||
s.src_dir = 'app/src/'
|
s.src_dir = 'app/src/'
|
||||||
s.init_logging_system()
|
s.init_logging_system()
|
||||||
@@ -158,14 +158,27 @@ class TestHypercornLogHndl:
|
|||||||
|
|
||||||
logging.getLogger('hypercorn.access').handlers = []
|
logging.getLogger('hypercorn.access').handlers = []
|
||||||
logging.getLogger('hypercorn.error').handlers = []
|
logging.getLogger('hypercorn.error').handlers = []
|
||||||
|
|
||||||
h.restore()
|
h.restore()
|
||||||
assert h.must_fix == False
|
assert h.must_fix == False
|
||||||
assert h.access_hndl == logging.getLogger('hypercorn.access').handlers
|
assert h.access_hndl == logging.getLogger('hypercorn.access').handlers
|
||||||
assert h.error_hndl == logging.getLogger('hypercorn.error').handlers
|
assert h.error_hndl == logging.getLogger('hypercorn.error').handlers
|
||||||
|
output = capsys.readouterr().out.rstrip()
|
||||||
|
assert "* Fix hypercorn.access setting" in output
|
||||||
|
assert "* Fix hypercorn.error setting" in output
|
||||||
|
|
||||||
h.restore()
|
h.restore() # second restore do nothing
|
||||||
assert h.must_fix == False
|
assert h.must_fix == False
|
||||||
|
output = capsys.readouterr().out.rstrip()
|
||||||
|
assert output == ''
|
||||||
|
|
||||||
|
h.save() # save the same values second time
|
||||||
|
assert h.must_fix == True
|
||||||
|
|
||||||
|
h.restore() # restore without changing the handlers
|
||||||
|
assert h.must_fix == False
|
||||||
|
output = capsys.readouterr().out.rstrip()
|
||||||
|
assert output == ''
|
||||||
|
|
||||||
|
|
||||||
class TestApp:
|
class TestApp:
|
||||||
|
|||||||
Reference in New Issue
Block a user