From c46d9874d46db91ff9527a423fb8e7d3e45dce4a Mon Sep 17 00:00:00 2001 From: Grigouze Date: Sun, 18 Dec 2016 13:24:58 +0100 Subject: [PATCH] Just add some tests to have full coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now it's 💯 % coverage, i don't if it's good or bad but it was easy :) --- test_maya.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test_maya.py b/test_maya.py index 8406b6c..649b495 100644 --- a/test_maya.py +++ b/test_maya.py @@ -1,3 +1,6 @@ +import pytest +from datetime import datetime + import maya @@ -43,10 +46,29 @@ def test_dt_tz_naive(): def test_random_date(): - d = maya.when('11-17-11') + d = maya.when('11-17-11 08:09:10') assert d.year == 2011 assert d.month == 11 assert d.day == 17 + assert d.hour == 8 + assert d.minute == 9 + assert d.second == 10 + assert d.microsecond == 0 + + +def test_print_date(capsys): + d = maya.when('11-17-11') + + print(d) + out, err = capsys.readouterr() + assert out == '\n' + + assert type(d.__format__()) is datetime + + +def test_invalid_date(): + with pytest.raises(ValueError): + d = maya.when('another day') def test_slang_date():