summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_time.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-32025: Add time.thread_time() (#4410)Antoine Pitrou2017-11-151-0/+57
| | | | | | | | | | | | | | * bpo-32025: Add time.thread_time() * Add missing #endif * Add NEWS blurb * Add docs and whatsnew * Address review comments * Review comments
* bpo-31784: Implement PEP 564: add time.time_ns() (#3989)Victor Stinner2017-11-021-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Add new time functions: * time.clock_gettime_ns() * time.clock_settime_ns() * time.monotonic_ns() * time.perf_counter_ns() * time.process_time_ns() * time.time_ns() Add new _PyTime functions: * _PyTime_FromTimespec() * _PyTime_FromNanosecondsObject() * _PyTime_FromTimeval() Other changes: * Add also os.times() tests to test_os. * pytime_fromtimeval() and pytime_fromtimeval() now return _PyTime_MAX or _PyTime_MIN on overflow, rather than undefined behaviour * _PyTime_FromNanoseconds() parameter type changes from long long to _PyTime_t
* time.clock() now emits a DeprecationWarning (GH-4020)Victor Stinner2017-10-171-10/+12
| | | | | | | | | | bpo-31803: time.clock() and time.get_clock_info('clock') now emit a DeprecationWarning warning. Replace time.clock() with time.perf_counter() in tests and demos. Remove also hasattr(time, 'monotonic') in test_time since time.monotonic() is now always available since Python 3.5.
* bpo-31786: Make functions in the select module blocking when timeout is a ↵Pablo Galindo2017-10-171-0/+3
| | | | small negative value. (#4003)
* weaken pthread_getcpuclockid test (more bpo-31596) (#3904)Benjamin Peterson2017-10-061-8/+1
| | | There just isn't much we can assert in a portable way.
* closes bpo-31596: Add an interface for pthread_getcpuclockid(3) (#3756)pdox2017-10-051-0/+20
|
* bpo-26669: Fix nan arg value error in pytime.c (#3085)Han Lee2017-09-081-0/+29
| | | | | | | | | | * Fix #26669 * Modify NaN check function and error message * Fix pytime.c when arg is nan * fix whitespace
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-4/+0
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)Serhiy Storchaka2017-06-281-0/+4
| | | | | | | Based on patch by Victor Stinner. Add private C API function _PyUnicode_AsUnicode() which is similar to PyUnicode_AsUnicode(), but checks for null characters.
* Fix typo in test_time.pyVictor Stinner2016-08-171-1/+1
|
* pytime: add _PyTime_check_mul_overflow() macro to avoid undefined behaviourVictor Stinner2015-09-101-1/+2
| | | | | | | | | | | Overflow test in test_FromSecondsObject() fails on FreeBSD 10.0 buildbot which uses clang. clang implements more aggressive optimization which gives different result than GCC on undefined behaviours. Check if a multiplication will overflow, instead of checking if a multiplicatin had overflowed, to avoid undefined behaviour. Add also debug information if the test on overflow fails.
* Fix test_time on platform with 32-bit time_t typeVictor Stinner2015-09-101-3/+6
| | | | Filter also values for check_float_rounding().
* Fix test_time on platform with 32-bit time_t typeVictor Stinner2015-09-101-5/+18
| | | | Filter values which would overflow when converted to a C time_t type.
* Fix test_time on WindowsVictor Stinner2015-09-101-9/+24
| | | | | | | * Filter values which would overflow on conversion to the C long type (for timeval.tv_sec). * Adjust also the message of OverflowError on PyTime conversions * test_time: add debug information if a timestamp conversion fails
* test_time: rewrite PyTime API rounding testsVictor Stinner2015-09-091-562/+234
| | | | | | | | | | Drop all hardcoded tests. Instead, reimplement each function in Python, usually using decimal.Decimal for the rounding mode. Add much more values to the dataset. Test various timestamp units from picroseconds to seconds, in integer and float. Enhance also _PyTime_AsSecondsDouble().
* Issue #23517: fromtimestamp() and utcfromtimestamp() methods ofVictor Stinner2015-09-081-135/+110
| | | | | | | | | | | | datetime.datetime now round microseconds to nearest with ties going to nearest even integer (ROUND_HALF_EVEN), as round(float), instead of rounding towards -Infinity (ROUND_FLOOR). pytime API: replace _PyTime_ROUND_HALF_UP with _PyTime_ROUND_HALF_EVEN. Fix also _PyTime_Divide() for negative numbers. _PyTime_AsTimeval_impl() now reuses _PyTime_Divide() instead of reimplementing rounding modes.
* Merge from 3.5Steve Dower2015-09-071-0/+13
|\
| * Issue #24917: time_strftime() buffer over-read.Steve Dower2015-09-071-0/+13
| |
| * Backing out 09b62202d9b7; the tests fail on Linux, and it needs a re-think.Larry Hastings2015-09-061-6/+0
| |
* | Issue #24917: Backed out changeset 09b62202d9b7Steve Dower2015-09-061-6/+0
|\ \
| * \ Issue #24917: Backed out changeset 09b62202d9b7Steve Dower2015-09-061-6/+0
| |\ \ | | |/ | |/|
* | | Issue #24917: time_strftime() Buffer Over-read. Patch by John Leitch.Steve Dower2015-09-061-0/+6
|\ \ \ | |/ /
| * | Issue #24917: time_strftime() Buffer Over-read. Patch by John Leitch.Steve Dower2015-09-051-0/+6
| | |
* | | Issue #23517: Fix implementation of the ROUND_HALF_UP rounding mode inVictor Stinner2015-09-041-6/+7
| | | | | | | | | | | | | | | datetime.datetime.fromtimestamp() and datetime.datetime.utcfromtimestamp(). microseconds sign should be kept before rounding.
* | | test_time: add tests on HALF_UP rounding mode for _PyTime_ObjectToTime_t() andVictor Stinner2015-09-041-40/+90
| | | | | | | | | | | | _PyTime_ObjectToTimespec()
* | | Issue #23517: test_time, skip a test checking a corner case on floating pointVictor Stinner2015-09-021-1/+3
| | | | | | | | | | | | rounding
* | | test_time: add more tests on HALF_UP rounding modeVictor Stinner2015-09-021-8/+28
| | |
* | | Issue #23517: Reintroduce unit tests for the old PyTime API since it's stillVictor Stinner2015-09-021-0/+154
| | | | | | | | | | | | used.
* | | Issue #23517: Add "half up" rounding mode to the _PyTime APIVictor Stinner2015-09-011-3/+61
|/ /
* | Closes #24244: Removes invalid test from test_timeSteve Dower2015-06-241-7/+0
| |
* | Issue #22117: Add a new _PyTime_FromSeconds() functionVictor Stinner2015-04-031-0/+7
| | | | | | | | | | Fix also _Py_InitializeEx_Private(): initialize time before initializing import, import_init() uses the _PyTime API (for thread locks).
* | Issue #22117, issue #23485: Fix _PyTime_AsMilliseconds() andVictor Stinner2015-04-011-4/+72
| | | | | | | | | | | | _PyTime_AsMicroseconds() rounding. Add also unit tests.
* | Issue #22117: Remove _PyTime_ROUND_DOWN and _PyTime_ROUND_UP rounding methodsVictor Stinner2015-03-301-87/+13
| | | | | | | | Use _PyTime_ROUND_FLOOR and _PyTime_ROUND_CEILING instead.
* | Issue #22117: Add _PyTime_ROUND_CEILING rounding method for timestampsVictor Stinner2015-03-301-4/+61
| | | | | | | | Add also more tests for ROUNd_FLOOR.
* | Issue #22117: Fix rounding and implement _PyTime_ROUND_FLOOR in:Victor Stinner2015-03-291-2/+2
| | | | | | | | | | | | - _PyTime_ObjectToTime_t() - _PyTime_ObjectToTimespec() - _PyTime_ObjectToTimeval()
* | Issue #22117: Add the new _PyTime_ROUND_FLOOR rounding method for the datetimeVictor Stinner2015-03-281-48/+18
| | | | | | | | | | module. time.clock_settime() now uses this rounding method instead of _PyTime_ROUND_DOWN to handle correctly dates before 1970.
* | Issue #22117: Write unit tests for _PyTime_AsTimeval()Victor Stinner2015-03-281-0/+38
| | | | | | | | | | | | | | * _PyTime_AsTimeval() now ensures that tv_usec is always positive * _PyTime_AsTimespec() now ensures that tv_nsec is always positive * _PyTime_AsTimeval() now returns an integer on overflow instead of raising an exception
* | Issue #22117: The signal modules uses the new _PyTime_t APIVictor Stinner2015-03-271-1/+28
| | | | | | | | | | * Add _PyTime_AsTimespec() * Add unit tests for _PyTime_AsTimespec()
* | Issue #22117: time.monotonic() now uses the new _PyTime_t APIVictor Stinner2015-03-271-10/+54
| | | | | | | | | | | | * Add _PyTime_FromNanoseconds() * Add _PyTime_AsSecondsDouble() * Add unit tests for _PyTime_AsSecondsDouble()
* | Issue #22117: Fix rounding in _PyTime_FromSecondsObject()Victor Stinner2015-03-271-79/+173
|/ | | | | | * Rename _PyTime_FromObject() to _PyTime_FromSecondsObject() * Add _PyTime_AsNanosecondsObject() and _testcapi.pytime_fromsecondsobject() * Add unit tests
* Issue #11188, #19748: mktime() returns -1 on error. On Linux, the tm_wday fieldVictor Stinner2014-02-211-0/+7
| | | | | | is used as a sentinel () to detect if -1 is really an error or a valid timestamp. On AIX, tm_wday is unchanged even on success and so cannot be used as a sentinel.
* Issue #19748: On AIX, time.mktime() now raises an OverflowError for yearVictor Stinner2014-02-211-1/+1
| | | | outsize range [1902; 2037].
* Issue #20320: select.select() and select.kqueue.control() now round the timeoutVictor Stinner2014-02-161-35/+95
| | | | | | aways from zero, instead of rounding towards zero. It should make test_asyncio more reliable, especially test_timeout_rounding() test.
* Issue #20532: Tests which use _testcapi now are marked as CPython only.Serhiy Storchaka2014-02-071-0/+3
|\
| * Issue #20532: Tests which use _testcapi now are marked as CPython only.Serhiy Storchaka2014-02-071-0/+3
| |
* | Issue #20101: Merge with 3.3Zachary Ware2014-01-021-1/+2
|\ \ | |/
| * Issue #20101: Allow test_monotonic to pass on Windows machines on whichZachary Ware2014-01-021-1/+2
| | | | | | | | | | | | time.get_clock_info('monotonic').resolution == 0.015600099999999999 This is just a workaround pending a real resolution to #20101.
* | (Merge 3.3) Close #19999: tolerate coarse time when testing time.monotonic() onVictor Stinner2013-12-161-1/+1
|\ \ | |/ | | | | very busy/slow buildbot
| * Close #19999: tolerate coarse time when testing time.monotonic() on veryVictor Stinner2013-12-161-1/+1
| | | | | | | | busy/slow buildbot
* | Issue 19572: More silently skipped tests explicitly skipped.Zachary Ware2013-12-081-2/+1
|\ \ | |/