mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Fix #50 - Catch YAML ScannerError
This commit is contained in:
@@ -60,5 +60,6 @@ def detect(stream):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except (yaml.parser.ParserError, yaml.reader.ReaderError):
|
||||
except (yaml.parser.ParserError, yaml.reader.ReaderError,
|
||||
yaml.scanner.ScannerError):
|
||||
return False
|
||||
|
||||
@@ -476,12 +476,14 @@ class TablibTestCase(unittest.TestCase):
|
||||
"""Test YAML format detection."""
|
||||
|
||||
_yaml = '- {age: 90, first_name: John, last_name: Adams}'
|
||||
_tsv = 'foo\tbar'
|
||||
_bunk = (
|
||||
'¡¡¡¡¡¡---///\n\n\n¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶'
|
||||
)
|
||||
|
||||
self.assertTrue(tablib.formats.yaml.detect(_yaml))
|
||||
self.assertFalse(tablib.formats.yaml.detect(_bunk))
|
||||
self.assertFalse(tablib.formats.yaml.detect(_tsv))
|
||||
|
||||
|
||||
def test_auto_format_detect(self):
|
||||
|
||||
Reference in New Issue
Block a user