-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #856 from sphinx-contrib/flexible-boolean-cfg-valu…
…es-with-ints config: flexible boolean processing from int value
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# Copyright Sphinx Confluence Builder Contributors (AUTHORS) | ||
|
||
from sphinxcontrib.confluencebuilder.util import str2bool | ||
import unittest | ||
|
||
|
||
class TestConfluenceUtilStr2Bool(unittest.TestCase): | ||
def test_util_str2bool_invalid(self): | ||
with self.assertRaises(ValueError): | ||
str2bool(None) | ||
|
||
with self.assertRaises(ValueError): | ||
str2bool(2) | ||
|
||
with self.assertRaises(ValueError): | ||
str2bool({}) | ||
|
||
def test_util_str2bool_true(self): | ||
self.assertTrue(str2bool('on')) | ||
self.assertTrue(str2bool('ON')) | ||
self.assertTrue(str2bool('true')) | ||
self.assertTrue(str2bool('TRUE')) | ||
self.assertTrue(str2bool('yes')) | ||
self.assertTrue(str2bool('YES')) | ||
self.assertTrue(str2bool('1')) | ||
self.assertTrue(str2bool(1)) | ||
|
||
def test_util_str2bool_false(self): | ||
self.assertFalse(str2bool('false')) | ||
self.assertFalse(str2bool('FALSE')) | ||
self.assertFalse(str2bool('no')) | ||
self.assertFalse(str2bool('NO')) | ||
self.assertFalse(str2bool('off')) | ||
self.assertFalse(str2bool('OFF')) | ||
self.assertFalse(str2bool('0')) | ||
self.assertFalse(str2bool(0)) |