Пример #1
0
    def test_error(self):
        os.environ['FLOAT_EMPTY'] = ''
        with self.assertRaises(TypeError):
            parsenvy.float('FLOAT_EMPTY')

        os.environ['FLOAT_STR'] = 'nope'
        with self.assertRaises(TypeError):
            parsenvy.float('FLOAT_STR')
Пример #2
0
 def test_default(self):
     self.assertEqual(parsenvy.float('FLOAT_NONE', 1.23), 1.23)
Пример #3
0
 def test_float(self):
     os.environ['FLOAT_1_23'] = '1.23'
     self.assertEqual(parsenvy.float('FLOAT_1_23'), 1.23)
Пример #4
0
 def test_none(self):
     self.assertIsNone(parsenvy.float('FLOAT_NONE'))
Пример #5
0
def test_float_positive_integer(monkeypatch):
    monkeypatch.setenv("foo", str(float(13)))
    assert parsenvy.float("foo") == float(13)
Пример #6
0
def test_float_empty(monkeypatch):
    monkeypatch.setenv("foo", "")
    with pytest.raises(TypeError):
        parsenvy.float("foo")
Пример #7
0
def test_float_invalid(monkeypatch):
    monkeypatch.setenv("foo", "bar")
    with pytest.raises(TypeError):
        parsenvy.float("foo")
Пример #8
0
def test_float_negative_zero(monkeypatch):
    monkeypatch.setenv("foo", str(float(-0)))
    assert parsenvy.float("foo") == float(-0)
Пример #9
0
def test_float_negative_decimal(monkeypatch):
    monkeypatch.setenv("foo", str(float(-13.42)))
    assert parsenvy.float("foo") == float(-13.42)