示例#1
0
    def test_error(self):
        os.environ['BOOL_EMPTY'] = ''
        with self.assertRaises(TypeError):
            parsenvy.bool('BOOL_EMPTY')

        os.environ['BOOL_STR'] = 'nope'
        with self.assertRaises(TypeError):
            parsenvy.bool('BOOL_STR')
示例#2
0
def test_bool_true_word(monkeypatch):
    monkeypatch.setenv("foo", "TrUe")  # capitalization is intentional
    assert parsenvy.bool("foo") is True
示例#3
0
def test_bool_empty(monkeypatch):
    monkeypatch.setenv("foo", "")
    with pytest.raises(ValueError):
        parsenvy.bool("foo")
示例#4
0
def test_bool_numbers(monkeypatch):
    monkeypatch.setenv("foo", "01")
    with pytest.raises(ValueError):
        parsenvy.bool("foo")
示例#5
0
def test_bool_neither(monkeypatch):
    monkeypatch.setenv("foo", "bar")
    with pytest.raises(ValueError):
        parsenvy.bool("foo")
示例#6
0
def test_bool_false_number(monkeypatch):
    monkeypatch.setenv("foo", "0")
    assert parsenvy.bool("foo") is False
示例#7
0
def test_bool_false_word(monkeypatch):
    monkeypatch.setenv("foo", "fAlSe")  # capitalization is intentional
    assert parsenvy.bool("foo") is False
示例#8
0
def test_bool_true_number(monkeypatch):
    monkeypatch.setenv("foo", "1")
    assert parsenvy.bool("foo") is True
示例#9
0
    def test_true(self):
        os.environ['BOOL_TRUE'] = 'true'
        self.assertTrue(parsenvy.bool('BOOL_TRUE'))

        os.environ['BOOL_1'] = '1'
        self.assertTrue(parsenvy.bool('BOOL_1'))
示例#10
0
 def test_default(self):
     self.assertTrue(parsenvy.bool('BOOL_NONE', True))
示例#11
0
 def test_none(self):
     self.assertIsNone(parsenvy.bool('BOOL_NONE'))
示例#12
0
    def test_false(self):
        os.environ['BOOL_FALSE'] = 'false'
        self.assertFalse(parsenvy.bool('BOOL_FALSE'))

        os.environ['BOOL_0'] = '0'
        self.assertFalse(parsenvy.bool('BOOL_0'))