33import shlex
44import string
55import unittest
6+ from test .support import cpython_only
7+ from test .support import import_helper
68
79
810# The original test data set was from shellwords, by Hartmut Goebel.
@@ -165,14 +167,12 @@ def testSplitNone(self):
165167 with self .assertRaises (ValueError ):
166168 shlex .split (None )
167169
168- # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
169- @unittest .expectedFailure
170+ @unittest .expectedFailure # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
170171 def testSplitPosix (self ):
171172 """Test data splitting with posix parser"""
172173 self .splitTest (self .posix_data , comments = True )
173174
174- # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
175- @unittest .expectedFailure
175+ @unittest .expectedFailure # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
176176 def testCompat (self ):
177177 """Test compatibility interface"""
178178 for i in range (len (self .data )):
@@ -313,8 +313,7 @@ def testEmptyStringHandling(self):
313313 s = shlex .shlex ("'')abc" , punctuation_chars = True )
314314 self .assertEqual (list (s ), expected )
315315
316- # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
317- @unittest .expectedFailure
316+ @unittest .expectedFailure # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
318317 def testUnicodeHandling (self ):
319318 """Test punctuation_chars and whitespace_split handle unicode."""
320319 ss = "\u2119 \u01b4 \u2602 \u210c \u00f8 \u1f24 "
@@ -334,6 +333,7 @@ def testQuote(self):
334333 unsafe = '"`$\\ !' + unicode_sample
335334
336335 self .assertEqual (shlex .quote ('' ), "''" )
336+ self .assertEqual (shlex .quote (None ), "''" )
337337 self .assertEqual (shlex .quote (safeunquoted ), safeunquoted )
338338 self .assertEqual (shlex .quote ('test file name' ), "'test file name'" )
339339 for u in unsafe :
@@ -342,6 +342,8 @@ def testQuote(self):
342342 for u in unsafe :
343343 self .assertEqual (shlex .quote ("test%s'name'" % u ),
344344 "'test%s'\" '\" 'name'\" '\" ''" % u )
345+ self .assertRaises (TypeError , shlex .quote , 42 )
346+ self .assertRaises (TypeError , shlex .quote , b"abc" )
345347
346348 def testJoin (self ):
347349 for split_command , command in [
@@ -354,8 +356,7 @@ def testJoin(self):
354356 joined = shlex .join (split_command )
355357 self .assertEqual (joined , command )
356358
357- # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
358- @unittest .expectedFailure
359+ @unittest .expectedFailure # TODO: RUSTPYTHON; ValueError: Error Retrieving Value
359360 def testJoinRoundtrip (self ):
360361 all_data = self .data + self .posix_data
361362 for command , * split_command in all_data :
@@ -371,6 +372,10 @@ def testPunctuationCharsReadOnly(self):
371372 with self .assertRaises (AttributeError ):
372373 shlex_instance .punctuation_chars = False
373374
375+ @cpython_only
376+ def test_lazy_imports (self ):
377+ import_helper .ensure_lazy_imports ('shlex' , {'collections' , 're' , 'os' })
378+
374379
375380# Allow this test to be used with old shlex.py
376381if not getattr (shlex , "split" , None ):
0 commit comments