summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/examplefiles/antlr_ANTLRv3.g (renamed from tests/examplefiles/ANTLRv3.g)0
-rw-r--r--tests/examplefiles/hybris_File.hy (renamed from tests/examplefiles/File.hy)0
-rw-r--r--tests/examplefiles/idl_sample.pro (renamed from tests/examplefiles/mg_sample.pro)0
-rw-r--r--tests/examplefiles/robotframework_test.txt (renamed from tests/examplefiles/robotframework.txt)0
-rw-r--r--tests/examplefiles/vbnet_test.bas (renamed from tests/examplefiles/test.bas)0
-rw-r--r--tests/test_examplefiles.py28
6 files changed, 17 insertions, 11 deletions
diff --git a/tests/examplefiles/ANTLRv3.g b/tests/examplefiles/antlr_ANTLRv3.g
index fbe6d654..fbe6d654 100644
--- a/tests/examplefiles/ANTLRv3.g
+++ b/tests/examplefiles/antlr_ANTLRv3.g
diff --git a/tests/examplefiles/File.hy b/tests/examplefiles/hybris_File.hy
index 9c86c641..9c86c641 100644
--- a/tests/examplefiles/File.hy
+++ b/tests/examplefiles/hybris_File.hy
diff --git a/tests/examplefiles/mg_sample.pro b/tests/examplefiles/idl_sample.pro
index 814d510d..814d510d 100644
--- a/tests/examplefiles/mg_sample.pro
+++ b/tests/examplefiles/idl_sample.pro
diff --git a/tests/examplefiles/robotframework.txt b/tests/examplefiles/robotframework_test.txt
index 63ba63e6..63ba63e6 100644
--- a/tests/examplefiles/robotframework.txt
+++ b/tests/examplefiles/robotframework_test.txt
diff --git a/tests/examplefiles/test.bas b/tests/examplefiles/vbnet_test.bas
index af5f2574..af5f2574 100644
--- a/tests/examplefiles/test.bas
+++ b/tests/examplefiles/vbnet_test.bas
diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py
index c3e3b2f7..4beaa0c7 100644
--- a/tests/test_examplefiles.py
+++ b/tests/test_examplefiles.py
@@ -32,23 +32,29 @@ def test_example_files():
if not os.path.isfile(absfn):
continue
- code = open(absfn).read()
+ print absfn
+ code = open(absfn, 'rb').read()
+ try:
+ code = code.decode('utf-8')
+ except UnicodeError:
+ code = code.decode('latin1')
outfn = os.path.join(outdir, fn)
- try:
- lx = get_lexer_for_filename(absfn, code=code)
- except ClassNotFound:
- if "_" not in fn:
+ lx = None
+ if '_' in fn:
+ try:
+ lx = get_lexer_by_name(fn.split('_')[0])
+ except ClassNotFound:
+ pass
+ if lx is None:
+ try:
+ lx = get_lexer_for_filename(absfn, code=code)
+ except ClassNotFound:
raise AssertionError('file %r has no registered extension, '
'nor is of the form <lexer>_filename '
'for overriding, thus no lexer found.'
- % fn)
- try:
- name, rest = fn.split("_", 1)
- lx = get_lexer_by_name(name)
- except ClassNotFound:
- raise AssertionError('no lexer found for file %r' % fn)
+ % fn)
yield check_lexer, lx, absfn, outfn
def check_lexer(lx, absfn, outfn):