MCPcopy Index your code
hub / github.com/python/cpython / testTokenTypes

Method testTokenTypes

Lib/test/test_shlex.py:256–274  ·  view source on GitHub ↗

Test that tokens are split with types as expected.

(self)

Source from the content-addressed store, hash-verified

254 self.assertEqual(ref, result, "While splitting '%s' [ws=True]" % ss)
255
256 def testTokenTypes(self):
257 """Test that tokens are split with types as expected."""
258 for source, expected in (
259 ('a && b || c',
260 [('a', 'a'), ('&&', 'c'), ('b', 'a'),
261 ('||', 'c'), ('c', 'a')]),
262 ):
263 s = shlex.shlex(source, punctuation_chars=True)
264 observed = []
265 while True:
266 t = s.get_token()
267 if t == s.eof:
268 break
269 if t[0] in s.punctuation_chars:
270 tt = 'c'
271 else:
272 tt = 'a'
273 observed.append((t, tt))
274 self.assertEqual(observed, expected)
275
276 def testPunctuationInWordChars(self):
277 """Test that any punctuation chars are removed from wordchars"""

Callers

nothing calls this directly

Calls 3

get_tokenMethod · 0.45
appendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected