def test_format_safe_control(): """Test handling of non-printing control characters.""" all_formatting = ''.join(formatting.CONTROL_FORMATTING) # no formatting chars should be stripped, # but a reset should be added to the end assert choose._format_safe(all_formatting) == all_formatting + '\x0f' # control characters not recognized as formatting should be stripped assert choose._format_safe( ''.join( c for c in formatting.CONTROL_NON_PRINTING if c not in formatting.CONTROL_FORMATTING )) == ''
def test_format_safe_basic(): """Test handling of basic whitespace.""" assert choose._format_safe( ''.join(UNICODE_ZS_CATEGORY)) == ''
def test_format_safe_pairs(text, cleaned): """Test expected formatting-safe string sanitization.""" assert choose._format_safe(text) == cleaned
def test_format_safe_future(text, cleaned): """Test future aspirations of efficiency.""" assert choose._format_safe(text) == cleaned
def test_format_safe_invalid_arg(): """Test for correct exception if non-string is passed.""" with pytest.raises(TypeError): choose._format_safe(None)