pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/901ea411bf51f59f2a4b0b4fec6f60d29c76ca05

097560d244c08.css" /> gh-121708: Improve test coverage for `unittest.util` (GH-121713) · python/cpython@901ea41 · GitHub
Skip to content

Commit 901ea41

Browse files
authored
gh-121708: Improve test coverage for unittest.util (GH-121713)
1 parent a2bec77 commit 901ea41

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import unittest
2+
from unittest.util import safe_repr, sorted_list_difference, unorderable_list_difference
3+
4+
5+
class TestUtil(unittest.TestCase):
6+
def test_safe_repr(self):
7+
class RaisingRepr:
8+
def __repr__(self):
9+
raise ValueError("Invalid repr()")
10+
11+
class LongRepr:
12+
def __repr__(self):
13+
return 'x' * 100
14+
15+
safe_repr(RaisingRepr())
16+
self.assertEqual(safe_repr('foo'), "'foo'")
17+
self.assertEqual(safe_repr(LongRepr(), short=True), 'x'*80 + ' [truncated]...')
18+
19+
def test_sorted_list_difference(self):
20+
self.assertEqual(sorted_list_difference([], []), ([], []))
21+
self.assertEqual(sorted_list_difference([1, 2], [2, 3]), ([1], [3]))
22+
self.assertEqual(sorted_list_difference([1, 2], [1, 3]), ([2], [3]))
23+
self.assertEqual(sorted_list_difference([1, 1, 1], [1, 2, 3]), ([], [2, 3]))
24+
self.assertEqual(sorted_list_difference([4], [1, 2, 3, 4]), ([], [1, 2, 3]))
25+
self.assertEqual(sorted_list_difference([1, 1], [2]), ([1], [2]))
26+
self.assertEqual(sorted_list_difference([2], [1, 1]), ([2], [1]))
27+
self.assertEqual(sorted_list_difference([1, 2], [1, 1]), ([2], []))
28+
29+
def test_unorderable_list_difference(self):
30+
self.assertEqual(unorderable_list_difference([], []), ([], []))
31+
self.assertEqual(unorderable_list_difference([1, 2], []), ([2, 1], []))
32+
self.assertEqual(unorderable_list_difference([], [1, 2]), ([], [1, 2]))
33+
self.assertEqual(unorderable_list_difference([1, 2], [1, 3]), ([2], [3]))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy