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 -*- # -*- coding: utf-8 -*-
# vim: set filetype=python
import os import os

View file

@ -53,7 +53,7 @@ class LanguagesTestCase(utils.TestCase):
heartbeat = { heartbeat = {
'language': u('Python'), 'language': u('Python'),
'lines': 26, 'lines': 27,
'entity': os.path.realpath(entity), 'entity': os.path.realpath(entity),
'project': u(os.path.basename(os.path.realpath('.'))), 'project': u(os.path.basename(os.path.realpath('.'))),
'dependencies': ANY, 'dependencies': ANY,
@ -66,7 +66,7 @@ class LanguagesTestCase(utils.TestCase):
u('dependencies'): ANY, u('dependencies'): ANY,
u('language'): u('Python'), u('language'): u('Python'),
u('lineno'): None, u('lineno'): None,
u('lines'): 26, u('lines'): 27,
} }
expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os'] expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os']
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 lexer = lexer1
if (lexer2 and accuracy2 and if (lexer2 and accuracy2 and
(not accuracy1 or accuracy2 > accuracy1)): (not accuracy1 or accuracy2 > accuracy1)):
lexer = lexer2 lexer = lexer2 # pragma: nocover
return lexer return lexer
@ -84,7 +84,7 @@ def guess_lexer_using_filename(file_name, text):
if lexer is not None: if lexer is not None:
try: try:
accuracy = lexer.analyse_text(text) accuracy = lexer.analyse_text(text)
except: except: # pragma: nocover
pass pass
return lexer, accuracy return lexer, accuracy
@ -101,19 +101,19 @@ def guess_lexer_using_modeline(text):
file_type = None file_type = None
try: try:
file_type = get_filetype_from_buffer(text) file_type = get_filetype_from_buffer(text)
except: except: # pragma: nocover
pass pass
if file_type is not None: if file_type is not None:
try: try:
lexer = get_lexer_by_name(file_type) lexer = get_lexer_by_name(file_type)
except ClassNotFound: except ClassNotFound: # pragma: nocover
pass pass
if lexer is not None: if lexer is not None:
try: try:
accuracy = lexer.analyse_text(text) accuracy = lexer.analyse_text(text)
except: except: # pragma: nocover
pass pass
return lexer, accuracy return lexer, accuracy