Skip to content

Commit

Permalink
Merge pull request #900 from sphinx-contrib/handle-empty-str-publish-…
Browse files Browse the repository at this point in the history
…debug

config: handle empty-str publish-debug
  • Loading branch information
jdknight authored Mar 3, 2024
2 parents 336e231 + 0f3b173 commit e96bf0a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sphinxcontrib/confluencebuilder/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ def apply_defaults(builder):

# ensure confluence_publish_debug is set with its expected enum value
publish_debug = conf.confluence_publish_debug
if publish_debug is not None and publish_debug is not False:
if not isinstance(publish_debug, PublishDebug):
# a boolean-provided publish debug is deprecated, but we will accept
# it as its original implementation as an indication to enable
# urllib3 logs
if publish_debug is True:
conf.confluence_publish_debug = PublishDebug.urllib3
elif not isinstance(publish_debug, PublishDebug):
elif isinstance(publish_debug, str) and publish_debug:
conf.confluence_publish_debug = PublishDebug[publish_debug.lower()]
else:
conf.confluence_publish_debug = PublishDebug.none
else:
conf.confluence_publish_debug = PublishDebug.none

if conf.confluence_publish_intersphinx is None:
conf.confluence_publish_intersphinx = True
Expand Down
19 changes: 19 additions & 0 deletions tests/unit-tests/test_config_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,25 @@ def test_config_check_publish(self):
with self.assertRaises(ConfluenceConfigError):
self._try_config()

def test_config_check_publish_debug(self):
self.config['confluence_publish_debug'] = ''
self._try_config()

self.config['confluence_publish_debug'] = 'urllib3'
self._try_config()

self.config['confluence_publish_debug'] = 'unknown-entry'
with self.assertRaises(ConfluenceConfigError):
self._try_config()

self.config['confluence_publish_debug'] = [1, 2, 3]
with self.assertRaises(ConfluenceConfigError):
self._try_config()

self.config['confluence_publish_debug'] = True
with self.assertRaises(SphinxWarning):
self._try_config()

def test_config_check_publish_delay(self):
self.config['confluence_publish_delay'] = 0.3
self._try_config()
Expand Down

0 comments on commit e96bf0a

Please sign in to comment.