Пример #1
0
    def test_yearfrac_basis_1_sub_year(self):
        assert 11 / 365 == pytest.approx(
            yearfrac(date(2015, 4, 20), date(2015, 5, 1), 1))

        assert 11 / 366 == pytest.approx(
            yearfrac(date(2016, 4, 20), date(2016, 5, 1), 1))

        assert 316 / 366 == pytest.approx(
            yearfrac(date(2016, 2, 20), date(2017, 1, 1), 1))

        assert 61 / 366 == pytest.approx(
            yearfrac(date(2015, 12, 31), date(2016, 3, 1), 1))
Пример #2
0
 def test_yearfrac_basis_4(self):
     assert 7.302777778 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 4))
Пример #3
0
 def test_yearfrac_inverted(self):
     assert yearfrac(date(2008, 1, 1), date(2015, 4, 20)) == pytest.approx(
         yearfrac(date(2015, 4, 20), date(2008, 1, 1)))
Пример #4
0
 def test_yearfrac_basis_2(self):
     assert 7.405555556 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 2))
Пример #5
0
 def test_yearfrac_basis_3(self):
     assert 7.304109589 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 3))
Пример #6
0
 def test_basis_must_be_between_0_and_4(self):
     assert NUM_ERROR == yearfrac(1, 2, 5)
Пример #7
0
 def test_yearfrac_basis_1(self):
     assert 7.299110198 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 1))
Пример #8
0
 def test_end_date_must_be_positive(self):
     assert NUM_ERROR == yearfrac(0, -1)
Пример #9
0
 def test_start_date_must_be_positive(self):
     assert NUM_ERROR == yearfrac(-1, 0)
Пример #10
0
 def test_end_date_must_be_number(self):
     assert VALUE_ERROR == yearfrac(1, 'not a number')
Пример #11
0
 def test_start_date_must_be_number(self):
     assert VALUE_ERROR == yearfrac('not a number', 1)
Пример #12
0
 def test_yearfrac_basis_0_feb_eom(self, start, end, expected):
     assert expected == pytest.approx(yearfrac(start, end, 0))