MCPcopy Index your code
hub / github.com/RustPython/RustPython / testTokenTypes

Method testTokenTypes

Lib/test/test_shlex.py:258–276  ·  view source on GitHub ↗

Test that tokens are split with types as expected.

(self)

Source from the content-addressed store, hash-verified

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