Ejemplo n.º 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')
Ejemplo n.º 2
0
def test_bool_true_word(monkeypatch):
    monkeypatch.setenv("foo", "TrUe")  # capitalization is intentional
    assert parsenvy.bool("foo") is True
Ejemplo n.º 3
0
def test_bool_empty(monkeypatch):
    monkeypatch.setenv("foo", "")
    with pytest.raises(ValueError):
        parsenvy.bool("foo")
Ejemplo n.º 4
0
def test_bool_numbers(monkeypatch):
    monkeypatch.setenv("foo", "01")
    with pytest.raises(ValueError):
        parsenvy.bool("foo")
Ejemplo n.º 5
0
def test_bool_neither(monkeypatch):
    monkeypatch.setenv("foo", "bar")
    with pytest.raises(ValueError):
        parsenvy.bool("foo")
Ejemplo n.º 6
0
def test_bool_false_number(monkeypatch):
    monkeypatch.setenv("foo", "0")
    assert parsenvy.bool("foo") is False
Ejemplo n.º 7
0
def test_bool_false_word(monkeypatch):
    monkeypatch.setenv("foo", "fAlSe")  # capitalization is intentional
    assert parsenvy.bool("foo") is False
Ejemplo n.º 8
0
def test_bool_true_number(monkeypatch):
    monkeypatch.setenv("foo", "1")
    assert parsenvy.bool("foo") is True
Ejemplo n.º 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'))
Ejemplo n.º 10
0
 def test_default(self):
     self.assertTrue(parsenvy.bool('BOOL_NONE', True))
Ejemplo n.º 11
0
 def test_none(self):
     self.assertIsNone(parsenvy.bool('BOOL_NONE'))
Ejemplo n.º 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'))