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 700c273

Browse filesBrowse files
committed
Add some basic tests
1 parent 4005ee3 commit 700c273
Copy full SHA for 700c273

File tree

Expand file treeCollapse file tree

1 file changed

+40
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+40
-0
lines changed
Open diff view settings
Collapse file

‎Lib/test/test_tag_strings.py‎

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import unittest
2+
3+
class TagStringTests(unittest.TestCase):
4+
5+
def test_basic(self):
6+
def tag(*args):
7+
return "Spam"
8+
self.assertEqual(tag"ham", "Spam")
9+
self.assertEqual(tag"...{ham}...{eggs}...", "Spam")
10+
11+
def test_tag_call(self):
12+
def tag(*args):
13+
return args
14+
self.assertEqual(tag"ham", ("ham",))
15+
res = tag"... {ham and eggs} ..."
16+
self.assertEqual(len(res), 3)
17+
self.assertEqual(res[0], "... ")
18+
func, string, conv, spec = res[1]
19+
ham = 42
20+
eggs = "delicious"
21+
self.assertEqual(func(), "delicious")
22+
self.assertEqual(string, "ham and eggs")
23+
self.assertEqual(conv, None)
24+
self.assertEqual(spec, None)
25+
self.assertEqual(res[2], " ...")
26+
27+
def test_tag_call_with_conversion(self):
28+
def tag(*args):
29+
return args
30+
res = tag"{ham!r:spec}"
31+
func, string, conv, spec = res[0]
32+
ham = 42
33+
self.assertEqual(func(), 42)
34+
self.assertEqual(string, "ham")
35+
self.assertEqual(conv, "r")
36+
self.assertEqual(spec, "spec")
37+
38+
39+
if __name__ == "__main__":
40+
unittest.main()

0 commit comments

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