Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve coverage in test_isoparser #879

Merged
merged 2 commits into from Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Expand Up @@ -43,6 +43,7 @@ switch, and thus all their contributions are dual-licensed.
- Dominik Kozaczko <dominik@MASKED>
- Elliot Hughes <elliot.hughes@gmail.com> (gh: @ElliotJH) **D**
- Elvis Pranskevichus <el@MASKED>
- Fan Huang <fanhuang.scb@gmail.com>(gh: @fhuang5) **D**
- Florian Rathgeber (gh: @kynan) **D**
- Gabriel Bianconi <gabriel@MASKED> (gh: @GabrielBianconi) **D**
- Gabriel Poesia <gabriel.poesia@MASKED>
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/879.misc.rst
@@ -0,0 +1,3 @@
Fixed a minor bug in ``test_isoparser`` related to ``bytes``/``str`` handling.
Fixed by @fhuang5 (gh issue #776, gh pr #879)

20 changes: 10 additions & 10 deletions dateutil/test/test_isoparser.py
Expand Up @@ -77,13 +77,13 @@ def _isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset,
dtstr = dt.strftime(fmt)

if microsecond_precision is not None:
if not fmt.endswith('%f'):
if not fmt.endswith('%f'): # pragma: nocover
raise ValueError('Time format has no microseconds!')

if microsecond_precision != 6:
if microsecond_precision != 6:
dtstr = dtstr[:-(6 - microsecond_precision)]
elif microsecond_precision > 6:
raise ValueError('Precision must be 1-6')
elif microsecond_precision > 6: # pragma: nocover
raise ValueError('Precision must be 1-6')

dtstr += offset_str

Expand Down Expand Up @@ -286,8 +286,8 @@ def test_iso_with_sep_raises(sep_act, valid_sep, exception):
parser.isoparse(isostr)


@pytest.mark.xfail()
@pytest.mark.parametrize('isostr,exception', [
@pytest.mark.xfail()
@pytest.mark.parametrize('isostr,exception', [ # pragma: nocover
('20120425T01:2000', ValueError), # Inconsistent time separators
])
def test_iso_raises_failing(isostr, exception):
Expand Down Expand Up @@ -454,9 +454,9 @@ def __make_time_examples():
@pytest.mark.parametrize('as_bytes', [True, False])
def test_isotime(time_val, time_fmt, as_bytes):
tstr = time_val.strftime(time_fmt)
if isinstance(time_val, six.text_type) and as_bytes:
if isinstance(tstr, six.text_type) and as_bytes:
tstr = tstr.encode('ascii')
elif isinstance(time_val, bytes) and not as_bytes:
elif isinstance(tstr, bytes) and not as_bytes:
tstr = tstr.decode('ascii')

iparser = isoparser()
Expand Down Expand Up @@ -505,8 +505,8 @@ def test_isotime_raises(isostr, exception):
iparser.parse_isotime(isostr)


@pytest.mark.xfail()
@pytest.mark.parametrize('isostr,exception', [
@pytest.mark.xfail()
@pytest.mark.parametrize('isostr,exception', [ # pragma: nocover
('14:3015', ValueError), # Inconsistent separator use
('201202', ValueError) # Invalid ISO format
])
Expand Down