add testcase for vim modeline

This commit is contained in:
Alan Hamlett 2016-04-18 17:00:42 +02:00
parent 0eec684234
commit 2437fb6b6d
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# vim: set filetype=python
import os, sys
import django
from app import *
from flask import session
import simplejson as json
from . import privatemodule
from jinja import tags
from pygments.lexers import BaseLexer
from . import LocalClass
from . import MyClass as MyParser
from ..compat import u
from sqlalchemy import (
functions as sqlfunctions,
orm as sqlorm,
)
try:
from mock import ANY
except ImportError:
from unittest.mock import ANY
class MyClass(object):
"""this class
"""
def method1(self):
a = 1 + 2
b = 'hello world!'
for x in y:
print(x)
raise Exception()

View file

@ -87,3 +87,19 @@ class LanguagesTestCase(utils.TestCase):
result = guess_language(source_file) result = guess_language(source_file)
mock_guess_lexer.assert_called_once_with(source_file) mock_guess_lexer.assert_called_once_with(source_file)
self.assertEquals(result, (None, None)) self.assertEquals(result, (None, None))
def test_guess_language_from_vim_modeline(self):
response = Response()
response.status_code = 500
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python_without_extension'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
language = u('Python')
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['language'], language)