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
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
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
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
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