示例#1
0
def test_fiscal_substitute(fye, test_date, string, output):
    with mock.patch('fava.util.date.datetime.date') as mock_date:
        mock_date.today.return_value = _to_date(test_date)
        mock_date.side_effect = date
        if output is None:
            with pytest.raises(ValueError):
                substitute(string, fye)
        else:
            assert substitute(string, fye) == output
示例#2
0
def test_fiscal_substitute(fye, test_date, string, output):
    with mock.patch("fava.util.date.datetime.date") as mock_date:
        mock_date.today.return_value = _to_date(test_date)
        mock_date.side_effect = date
        if output is None:
            with pytest.raises(ValueError):
                substitute(string, fye)
        else:
            assert substitute(string, fye) == output
示例#3
0
def test_fiscal_substitute(fye: str, test_date: str, string: str,
                           output: Optional[str]) -> None:
    fye = parse_fye_string(fye)
    with mock.patch("fava.util.date.datetime.date") as mock_date:
        mock_date.today.return_value = _to_date(test_date)
        mock_date.side_effect = date
        if output is None:
            with pytest.raises(ValueError):
                substitute(string, fye)
        else:
            assert substitute(string, fye) == output
示例#4
0
def test_substitute(string, output):
    # Mock the imported datetime.date in fava.util.date module
    # Ref:
    # http://www.voidspace.org.uk/python/mock/examples.html#partial-mocking
    with mock.patch('fava.util.date.datetime.date') as mock_date:
        mock_date.today.return_value = _to_date('2016-06-24')
        mock_date.side_effect = date
        assert substitute(string) == output
示例#5
0
def test_substitute(string, output):
    # Mock the imported datetime.date in fava.util.date module
    # Ref:
    # http://www.voidspace.org.uk/python/mock/examples.html#partial-mocking
    with mock.patch("fava.util.date.datetime.date") as mock_date:
        mock_date.today.return_value = _to_date("2016-06-24")
        mock_date.side_effect = date
        assert substitute(string) == output