Skip to content

Commit

Permalink
Merge pull request #879 from fhuang5/isoparser_coverage
Browse files Browse the repository at this point in the history
Improve coverage in test_isoparser
  • Loading branch information
pganssle committed Feb 24, 2019
2 parents 18d3f04 + 69f7884 commit 222795d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
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

0 comments on commit 222795d

Please sign in to comment.