From 8225a8e2628b5f576be049bf71575085de1f997d Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Wed, 7 Mar 2018 16:59:58 -0500 Subject: [PATCH] issue 6664: Fix typo in get_words --- spyder/utils/introspection/utils.py | 2 +- spyder/utils/tests/data/example.java | 1 + spyder/utils/tests/data/example.md | 2 ++ spyder/utils/tests/test_get_words.py | 9 +++++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spyder/utils/introspection/utils.py b/spyder/utils/introspection/utils.py index 6d5c739b4db..d805bbe8a4c 100644 --- a/spyder/utils/introspection/utils.py +++ b/spyder/utils/introspection/utils.py @@ -231,7 +231,7 @@ def get_words(file_path=None, content=None, extension=None): if extension in ['.css']: regex = re.compile(r'([^a-zA-Z-])') - elif extension in ['.R', '.c', 'md', '.cpp, java', '.py']: + elif extension in ['.R', '.c', '.md', '.cpp', '.java', '.py']: regex = re.compile(r'([^a-zA-Z_])') else: regex = re.compile(r'([^a-zA-Z])') diff --git a/spyder/utils/tests/data/example.java b/spyder/utils/tests/data/example.java index 6503341972e..fe4f62719b2 100644 --- a/spyder/utils/tests/data/example.java +++ b/spyder/utils/tests/data/example.java @@ -7,6 +7,7 @@ public class HelloWorld { public static void main(String[] args) { // Prints "Hello, World" to the terminal window. + // test_underscore System.out.println("Hello, World"); } diff --git a/spyder/utils/tests/data/example.md b/spyder/utils/tests/data/example.md index bf99c27330b..b8097ae6014 100644 --- a/spyder/utils/tests/data/example.md +++ b/spyder/utils/tests/data/example.md @@ -39,3 +39,5 @@ A paragraph after 1 blank line. print '3 backticks or' print 'indent 4 spaces' ``` + +under_score diff --git a/spyder/utils/tests/test_get_words.py b/spyder/utils/tests/test_get_words.py index 1e1cddfa449..46247216f1f 100644 --- a/spyder/utils/tests/test_get_words.py +++ b/spyder/utils/tests/test_get_words.py @@ -68,7 +68,8 @@ def test_get_words_java(): """Test for get word from java file syntax.""" expected_words = ['Compilation', 'Execution', 'Hello', 'HelloWorld', 'Prints', 'String', 'System', 'World', 'args', 'class', 'java', 'javac', 'main', 'out', - 'println', 'public', 'static', 'terminal', 'the', 'to', 'void', 'window'] + 'println', 'public', 'static', 'terminal', 'test_underscore', + 'the', 'to', 'void', 'window'] assert sorted(expected_words) == sorted(get_words_by_filename("example.java")) assert sorted(expected_words) == sorted(get_words_by_content("example.java")) @@ -76,12 +77,12 @@ def test_get_words_cplusplus(): """Test for get word from C++ file syntax.""" expected_words = ['Consider', 'Create', 'Implement', 'Obj', 'ObjContainer', 'Postfix', 'Prefix', 'Return', 'SmartPointer', 'Static', - 'Zero', 'a', 'above', 'access', 'actual', 'add', 'an', 'back', + 'Zero', 'a', 'above', 'access', 'actual', 'add', 'an', 'bool', 'call', 'class', 'const', 'container', 'cout', 'definitions', 'do', 'end', 'endl', 'f', 'false', 'for', 'friend', 'g', 'i', 'if', 'implement', 'include', 'index', 'indicates', 'int', 'iostream', 'iterator', 'j', 'list', 'main', 'member', 'method', 'namespace', 'o', 'obj', 'objc', - 'oc', 'of', 'operator', 'overload', 'pointer', 'public', 'push', 'return', + 'oc', 'of', 'operator', 'overload', 'pointer', 'public', 'push_back', 'return', 's', 'size', 'smart', 'sp', 'standard', 'static', 'std', 'sz', 'the', 'to', 'true', 'using', 'value', 'vector', 'version', 'void', 'while'] assert sorted(expected_words) == sorted(get_words_by_filename("example.cpp")) @@ -93,7 +94,7 @@ def test_get_words_markdown(): 'Italic', 'Link', 'List', 'One', 'Rule', 'Three', 'Two', 'a', 'after', 'b', 'backticks', 'blank', 'block', 'code', 'com', 'http', 'indent', 'jpg', 'line', 'or', 'org', 'paragraph', 'png', 'print', 'spaces', - 'url', 'with'] + 'under_score', 'url', 'with'] assert sorted(expected_words) == sorted(get_words_by_filename("example.md")) assert sorted(expected_words) == sorted(get_words_by_content("example.md"))