Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def check_ns(sec, ns):
check_ns(time.clock_gettime(time.CLOCK_REALTIME),
time.clock_gettime_ns(time.CLOCK_REALTIME))

@unittest.skipUnless(hasattr(time, 'clock'),
'need time.clock()')
def test_clock(self):
with self.assertWarns(DeprecationWarning):
time.clock()
Expand Down Expand Up @@ -312,7 +314,13 @@ def test_ctime(self):
self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
t = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, -1))
self.assertEqual(time.ctime(t), 'Sat Jan 1 00:00:00 2000')
for year in [-100, 100, 1000, 2000, 2050, 10000]:
# the largest year on VxWorks is 2038
Comment thread
pxinwr marked this conversation as resolved.
Outdated
if 'vxworks' in sys.platform :
range = [-100, 100, 1000, 2000]
else:
range = [-100, 100, 1000, 2000, 2050, 10000]

for year in range:
try:
testval = time.mktime((year, 1, 10) + (0,)*6)
except (ValueError, OverflowError):
Expand Down Expand Up @@ -549,8 +557,10 @@ def test_localtime_failure(self):
self.assertRaises(ValueError, time.ctime, float("nan"))

def test_get_clock_info(self):
clocks = ['clock', 'monotonic', 'perf_counter', 'process_time', 'time']

if hasattr(time, 'clock'):
clocks = ['clock', 'monotonic', 'perf_counter', 'process_time', 'time']
else:
clocks = ['monotonic', 'perf_counter', 'process_time', 'time']
Comment thread
pxinwr marked this conversation as resolved.
Outdated
for name in clocks:
if name == 'clock':
with self.assertWarns(DeprecationWarning):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add time module support and fix test_time faiures for VxWorks.
4 changes: 2 additions & 2 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ perf_counter(_Py_clock_info_t *info)
return _PyFloat_FromPyTime(t);
}

#if defined(MS_WINDOWS) || defined(HAVE_CLOCK)
#if (defined(MS_WINDOWS) || defined(HAVE_CLOCK)) && !defined(__VXWORKS__)
#define PYCLOCK
static PyObject*
pyclock(_Py_clock_info_t *info)
Expand Down Expand Up @@ -765,7 +765,7 @@ time_strftime(PyObject *self, PyObject *args)
return NULL;
}

#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX)
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__)
Comment thread
pxinwr marked this conversation as resolved.
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
PyErr_SetString(PyExc_ValueError,
"strftime() requires year in [1; 9999]");
Expand Down