test vim modeline detection

This commit is contained in:
Alan Hamlett 2015-09-06 20:46:57 -07:00
parent 0c42ae8a70
commit 5808a1d77c
3 changed files with 8 additions and 7 deletions

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# vim: set filetype=python
import os

View file

@ -53,7 +53,7 @@ class LanguagesTestCase(utils.TestCase):
heartbeat = {
'language': u('Python'),
'lines': 26,
'lines': 27,
'entity': os.path.realpath(entity),
'project': u(os.path.basename(os.path.realpath('.'))),
'dependencies': ANY,
@ -66,7 +66,7 @@ class LanguagesTestCase(utils.TestCase):
u('dependencies'): ANY,
u('language'): u('Python'),
u('lineno'): None,
u('lines'): 26,
u('lines'): 27,
}
expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os']
expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os']

View file

@ -63,7 +63,7 @@ def smart_guess_lexer(file_name):
lexer = lexer1
if (lexer2 and accuracy2 and
(not accuracy1 or accuracy2 > accuracy1)):
lexer = lexer2
lexer = lexer2 # pragma: nocover
return lexer
@ -84,7 +84,7 @@ def guess_lexer_using_filename(file_name, text):
if lexer is not None:
try:
accuracy = lexer.analyse_text(text)
except:
except: # pragma: nocover
pass
return lexer, accuracy
@ -101,19 +101,19 @@ def guess_lexer_using_modeline(text):
file_type = None
try:
file_type = get_filetype_from_buffer(text)
except:
except: # pragma: nocover
pass
if file_type is not None:
try:
lexer = get_lexer_by_name(file_type)
except ClassNotFound:
except ClassNotFound: # pragma: nocover
pass
if lexer is not None:
try:
accuracy = lexer.analyse_text(text)
except:
except: # pragma: nocover
pass
return lexer, accuracy