test truncating dependencies in TokenParser
This commit is contained in:
parent
3dd5e12d06
commit
e8884ffc8e
2 changed files with 15 additions and 1 deletions
|
@ -50,6 +50,20 @@ class DependenciesTestCase(utils.TestCase):
|
||||||
parser.tokens
|
parser.tokens
|
||||||
mock_extract_tokens.assert_called_once_with()
|
mock_extract_tokens.assert_called_once_with()
|
||||||
|
|
||||||
|
parser = TokenParser(None)
|
||||||
|
parser.append('one.two.three', truncate=True, truncate_to=1)
|
||||||
|
parser.append('one.two.three', truncate=True, truncate_to=2)
|
||||||
|
parser.append('one.two.three', truncate=True, truncate_to=3)
|
||||||
|
parser.append('one.two.three', truncate=True, truncate_to=4)
|
||||||
|
|
||||||
|
expected = [
|
||||||
|
'one',
|
||||||
|
'one.two',
|
||||||
|
'one.two.three',
|
||||||
|
'one.two.three',
|
||||||
|
]
|
||||||
|
self.assertEquals(parser.dependencies, expected)
|
||||||
|
|
||||||
def test_io_error_when_parsing_dependencies(self):
|
def test_io_error_when_parsing_dependencies(self):
|
||||||
response = Response()
|
response = Response()
|
||||||
response.status_code = 0
|
response.status_code = 0
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TokenParser(object):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
with open(self.source_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
with open(self.source_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||||
return self.lexer.get_tokens_unprocessed(fh.read(512000))
|
return self.lexer.get_tokens_unprocessed(fh.read(512000)) # pragma: nocover
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return []
|
return []
|
||||||
|
|
Loading…
Reference in a new issue