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')
def test_default(self): self.assertEqual(parsenvy.float('FLOAT_NONE', 1.23), 1.23)
def test_float(self): os.environ['FLOAT_1_23'] = '1.23' self.assertEqual(parsenvy.float('FLOAT_1_23'), 1.23)
def test_none(self): self.assertIsNone(parsenvy.float('FLOAT_NONE'))
def test_float_positive_integer(monkeypatch): monkeypatch.setenv("foo", str(float(13))) assert parsenvy.float("foo") == float(13)
def test_float_empty(monkeypatch): monkeypatch.setenv("foo", "") with pytest.raises(TypeError): parsenvy.float("foo")
def test_float_invalid(monkeypatch): monkeypatch.setenv("foo", "bar") with pytest.raises(TypeError): parsenvy.float("foo")
def test_float_negative_zero(monkeypatch): monkeypatch.setenv("foo", str(float(-0))) assert parsenvy.float("foo") == float(-0)
def test_float_negative_decimal(monkeypatch): monkeypatch.setenv("foo", str(float(-13.42))) assert parsenvy.float("foo") == float(-13.42)