New submission from Michael Osipov <1983-01...@gmx.net>:

I see a test failure on HP-UX:
> test_negative (test.test_time.TestStrftime4dyear) ... FAIL
> ======================================================================
> FAIL: test_negative (test.test_time.TestStrftime4dyear)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/var/osipovmi/cpython/Lib/test/test_time.py", line 687, in 
> test_negative
>     return super().test_negative()
>   File "/var/osipovmi/cpython/Lib/test/test_time.py", line 713, in 
> test_negative
>     self.assertEqual(self.yearstr(-1), self._format % -1)
> AssertionError: '-0001' != '-001'
> - -0001
> ?  -
> + -001

The bug is in the test class, not cause by HP-UX.
Lib/test/test_time.py:713 says "self.assertEqual(self.yearstr(-1), self._format 
% -1)" where self._format is set in line 654 to "_format = '%04d'" because
> Python 3.7.0+ (heads/3.7-dirty:ea8835fb30, Aug 14 2018, 14:44:19) [C] on 
> hp-ux11
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import time
> >>> time.strftime('%Y', (1,) + (0,) * 8)
> '0001'

Unfortunately, the zero padding in printf() applies to the entire string 
length. So
> >>> "%+04d" % -1
> '-001'

on HP-UX, Linux and FreeBSD.

The format string must add an additional zero for negative numbers.

----------
components: Tests
messages: 323519
nosy: michael-o
priority: normal
severity: normal
status: open
title: test_time incorrectly defined
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34404>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to