Test that tokens are split with types as expected.
(self)
| 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""" |
nothing calls this directly
no test coverage detected