Skip to content

Commit

Permalink
LanguageDefinition: Adapt to new coala API
Browse files Browse the repository at this point in the history
  • Loading branch information
sils committed Nov 21, 2016
1 parent e494beb commit 76bb255
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bears/general/IndentationBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run(self,
language, coalang_dir=coalang_dir)
annotation_dict = dependency_results[AnnotationBear.name][0].contents
# sometimes can't convert strings with ':' to dict correctly
if ':' in list(lang_settings_dict["indent_types"]):
if ':' in dict(lang_settings_dict["indent_types"]).keys():
indent_types = dict(lang_settings_dict["indent_types"])
indent_types[':'] = ''
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use >= for development versions so that source builds always work
coala>=0.9.0.dev20161112225154
coala>=0.9.0.dev20161121104802
munkres3==1.*
pylint==1.*
autopep8==1.*
Expand Down
12 changes: 1 addition & 11 deletions tests/general/AnnotationBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AnnotationBearTest(unittest.TestCase):

def setUp(self):
self.section1 = Section("")
self.section1.append(Setting('language', 'python3'))
self.section1.append(Setting('language', 'python 3'))
self.python_uut = AnnotationBear(self.section1, Queue())
self.section2 = Section("")
self.section2.append(Setting('language', 'c'))
Expand Down Expand Up @@ -123,16 +123,6 @@ def test_combined_strings(self):
self.assertIn(string3, results[0].contents['strings'])
self.assertEqual(results[0].contents['comments'], ())

def test_external_coalang(self):
self.section1.append(Setting('coalang_dir', escape(os.path.join(
os.path.dirname(__file__), 'test_files'), '\\')))
self.section1.append(Setting('language', 'test'))
uut = AnnotationBear(self.section1, Queue())
text = ['//comment line 1\n', '"""string line 2"""']
with execute_bear(uut, "F", text) as result:
self.assertNotEqual(result[0].contents['strings'], ())
self.assertNotEqual(result[0].contents['comments'], ())

def test_no_coalang(self):
self.section1.append(Setting('language', 'Valyrian'))
text = ["Valar Morghulis"]
Expand Down
16 changes: 13 additions & 3 deletions tests/general/IndentationBearTest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

from queue import Queue
import os

Expand All @@ -7,16 +8,25 @@
from coala_utils.string_processing.Core import escape
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting
from coalib.bearlib.languages import Language


@Language
class TestLanguage:
string_delimiters = {'"': '"', "'": "'"}
multiline_string_delimiters = {'"""': '"""', 'R("': '")'}
multiline_comment_delimiters = {'/*': '*/'}
comment_delimiter = '/', '#'
indent_types = {'{': '}', '<': '>', ':': ''}
encapsulators = {'(': ')', '[': ']'}


class IndentationBearTest(unittest.TestCase):

def setUp(self):
self.section = Section("")
self.section.append(Setting('language', 'test'))
self.section.append(Setting('language', 'TestLanguage'))
self.section.append(Setting('use_spaces', False))
self.section.append(Setting('coalang_dir', escape(os.path.join(
os.path.dirname(__file__), "test_files"), '\\')))
self.dep_uut = AnnotationBear(self.section, Queue())

def get_results(self, file, section=None):
Expand Down
6 changes: 0 additions & 6 deletions tests/general/test_files/test.coalang

This file was deleted.

0 comments on commit 76bb255

Please sign in to comment.