@@ -15,6 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
import datetime
import errno
import io
import inspect
@@ -74,6 +75,26 @@ def test_bytes_output_stream(path):
actual = cliutil.bytes_output(path, stream)
assert actual is stream
@pytest.mark.parametrize('year,month,day', [
(2000, 1, 1),
(2016, 2, 29),
(2020, 12, 31),
])
def test_date_arg_valid(year, month, day):
arg = f'{year}-{month}-{day}'
expected = datetime.date(year, month, day)
assert cliutil.date_arg(arg) == expected
@pytest.mark.parametrize('arg', [
'2000',
'20-02-12',
'2019-02-29',
'two thousand',
def test_date_arg_invalid(arg):
with pytest.raises(ValueError):
cliutil.date_arg(arg)
@pytest.mark.parametrize('func_name', [
'bytes_output',
'text_output',