Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Tear down sphinx loggers that break test isolation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 19, 2017
1 parent 767520d commit b002d56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/z3c/recipe/sphinxdoc/tests/test_sphinxdoc.py
Expand Up @@ -12,6 +12,7 @@
#
##############################################################################

import logging
import shutil
import subprocess
import sys
Expand All @@ -38,10 +39,21 @@ def setUp(self):
os.chdir(self.tmpdir)
os.mkdir('bin')

# Sphinx likes to install handlers when you call its main methods.
# If we pass -W (and we do) those turn warnings into hard errors.
# This pollutes later tests. So be sure to tear those down.
self.handlers_before_set_up = logging.getLogger().handlers[:]

def tearDown(self):
os.chdir(self.here)
shutil.rmtree(self.tmpdir)

root_logger = logging.getLogger()
for handler in root_logger.handlers[:]:
root_logger.removeHandler(handler)
for handler in self.handlers_before_set_up:
root_logger.addHandler(handler)

def _makeOne(self, name='docs', options=None):
opts = {
'doc-eggs': 'z3c.recipe.sphinxdoc',
Expand Down

0 comments on commit b002d56

Please sign in to comment.