|
| 1 | +# Copyright 2022 The go-python Authors. All rights reserved. |
| 2 | +# Use of this source code is governed by a BSD-style |
| 3 | +# license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import time |
| 6 | + |
| 7 | +now = time.time() |
| 8 | +now = time.time_ns() |
| 9 | +now = time.clock() |
| 10 | + |
| 11 | +def notimplemented(fn, *args, **kwargs): |
| 12 | + try: |
| 13 | + fn(*args, **kwargs) |
| 14 | + print("error for %s(%s, %s)" % (fn,args,kwargs)) |
| 15 | + except NotImplementedError: |
| 16 | + pass |
| 17 | + |
| 18 | +notimplemented(time.clock_gettime) |
| 19 | +notimplemented(time.clock_settime) |
| 20 | + |
| 21 | +print("# sleep") |
| 22 | +time.sleep(0.1) |
| 23 | +try: |
| 24 | + time.sleep(-1) |
| 25 | + print("no error sleep(-1)") |
| 26 | +except ValueError as e: |
| 27 | + print("caught error: %s" % (e,)) |
| 28 | + pass |
| 29 | +try: |
| 30 | + time.sleep("1") |
| 31 | + print("no error sleep('1')") |
| 32 | +except TypeError as e: |
| 33 | + print("caught error: %s" % (e,)) |
| 34 | + pass |
| 35 | + |
| 36 | +notimplemented(time.gmtime) |
| 37 | +notimplemented(time.localtime) |
| 38 | +notimplemented(time.asctime) |
| 39 | +notimplemented(time.ctime) |
| 40 | +notimplemented(time.mktime, 1) |
| 41 | +notimplemented(time.strftime) |
| 42 | +notimplemented(time.strptime) |
| 43 | +notimplemented(time.tzset) |
| 44 | +notimplemented(time.monotonic) |
| 45 | +notimplemented(time.process_time) |
| 46 | +notimplemented(time.perf_counter) |
| 47 | +notimplemented(time.get_clock_info) |
| 48 | + |
| 49 | +print("OK") |
0 commit comments