Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2a2809

Browse filesBrowse files
miss-islingtonpicnixzvstinner
authored
[3.13] gh-125997: Increase test coverage for time.sleep() (GH-128751) (#128796)
gh-125997: Increase test coverage for `time.sleep()` (GH-128751) - Add tests for durations of invalid types. - Add tests for `int` and `float` durations, including signed zeroes durations. - Add tests for nonzero very small durations and durations close to the clock resolution. --------- (cherry picked from commit b70a567) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 1079619 commit f2a2809
Copy full SHA for f2a2809

File tree

Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed

‎Lib/test/test_time.py

Copy file name to clipboardExpand all lines: Lib/test/test_time.py
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,19 @@ def test_conversions(self):
157157
self.assertEqual(int(time.mktime(time.localtime(self.t))),
158158
int(self.t))
159159

160-
def test_sleep(self):
160+
def test_sleep_exceptions(self):
161+
self.assertRaises(TypeError, time.sleep, [])
162+
self.assertRaises(TypeError, time.sleep, "a")
163+
self.assertRaises(TypeError, time.sleep, complex(0, 0))
164+
161165
self.assertRaises(ValueError, time.sleep, -2)
162166
self.assertRaises(ValueError, time.sleep, -1)
163-
time.sleep(1.2)
167+
self.assertRaises(ValueError, time.sleep, -0.1)
168+
169+
def test_sleep(self):
170+
for value in [-0.0, 0, 0.0, 1e-100, 1e-9, 1e-6, 1, 1.2]:
171+
with self.subTest(value=value):
172+
time.sleep(value)
164173

165174
def test_epoch(self):
166175
# bpo-43869: Make sure that Python use the same Epoch on all platforms:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.