This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The entire module now has a standard test suite in pytest with full coverage.
- Loading branch information
Showing
18 changed files
with
1,555 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest~=3.6.1 | ||
pytest-cov~=2.5.1 | ||
codecov~=2.0.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
{ | ||
"samples": [ | ||
{ | ||
"coala": { | ||
"results": { | ||
"all": [], | ||
"all.autopep8": [ | ||
{ | ||
"additional_info": "", | ||
"affected_code": [ | ||
{ | ||
"end": { | ||
"column": 5, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 2 | ||
}, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"start": { | ||
"column": 5, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 2 | ||
} | ||
} | ||
], | ||
"aspect": "NoneType", | ||
"confidence": 100, | ||
"debug_msg": "", | ||
"diffs": null, | ||
"id": 281466453796115535461439422208028175619, | ||
"message": "E128 continuation line under-indented for visual indent", | ||
"message_arguments": {}, | ||
"message_base": "E128 continuation line under-indented for visual indent", | ||
"origin": "PycodestyleBear (E128)", | ||
"severity": 1 | ||
}, | ||
{ | ||
"additional_info": "", | ||
"affected_code": [ | ||
{ | ||
"end": { | ||
"column": 1, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 3 | ||
}, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"start": { | ||
"column": 1, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 3 | ||
} | ||
} | ||
], | ||
"aspect": "NoneType", | ||
"confidence": 100, | ||
"debug_msg": "", | ||
"diffs": null, | ||
"id": 86549142496323668488131828852516756744, | ||
"message": "E901 TokenError: EOF in multi-line statement", | ||
"message_arguments": {}, | ||
"message_base": "E901 TokenError: EOF in multi-line statement", | ||
"origin": "PycodestyleBear (E901)", | ||
"severity": 1 | ||
} | ||
], | ||
"all.linelength": [], | ||
"all.python": [], | ||
"all.yml": [], | ||
"cli": [] | ||
} | ||
}, | ||
"langserver": [ | ||
{ | ||
"severity": 2, | ||
"range": { | ||
"start": { | ||
"line": 1, | ||
"character": 4 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"character": 4 | ||
} | ||
}, | ||
"source": "coala", | ||
"message": "[all.autopep8] PycodestyleBear (E128): E128 continuation line under-indented for visual indent" | ||
}, | ||
{ | ||
"severity": 2, | ||
"range": { | ||
"start": { | ||
"line": 2, | ||
"character": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"character": 0 | ||
} | ||
}, | ||
"source": "coala", | ||
"message": "[all.autopep8] PycodestyleBear (E901): E901 TokenError: EOF in multi-line statement" | ||
} | ||
] | ||
}, | ||
{ | ||
"coala": { | ||
"results": { | ||
"all": [], | ||
"all.autopep8": [ | ||
{ | ||
"additional_info": "", | ||
"affected_code": [ | ||
{ | ||
"end": { | ||
"column": null, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 2 | ||
}, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"start": { | ||
"column": null, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 2 | ||
} | ||
} | ||
], | ||
"aspect": "NoneType", | ||
"confidence": 100, | ||
"debug_msg": "", | ||
"diffs": null, | ||
"id": 281466453796115535461439422208028175619, | ||
"message": "E128 continuation line under-indented for visual indent", | ||
"message_arguments": {}, | ||
"message_base": "E128 continuation line under-indented for visual indent", | ||
"origin": "PycodestyleBear (E128)", | ||
"severity": 1 | ||
}, | ||
{ | ||
"additional_info": "", | ||
"affected_code": [ | ||
{ | ||
"end": { | ||
"column": 1, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 3 | ||
}, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"start": { | ||
"column": 1, | ||
"file": "/home/ksdme/Work/gsoc/coala-ls/tests/resources/failure2.py", | ||
"line": 3 | ||
} | ||
} | ||
], | ||
"aspect": "NoneType", | ||
"confidence": 100, | ||
"debug_msg": "", | ||
"diffs": null, | ||
"id": 86549142496323668488131828852516756744, | ||
"message": "E901 TokenError: EOF in multi-line statement", | ||
"message_arguments": {}, | ||
"message_base": "E901 TokenError: EOF in multi-line statement", | ||
"origin": "PycodestyleBear (E901)", | ||
"severity": 1 | ||
} | ||
], | ||
"all.linelength": [], | ||
"all.python": [], | ||
"all.yml": [], | ||
"cli": [] | ||
} | ||
}, | ||
"langserver": [ | ||
{ | ||
"severity": 2, | ||
"range": { | ||
"start": { | ||
"line": 1, | ||
"character": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"character": 0 | ||
} | ||
}, | ||
"source": "coala", | ||
"message": "[all.autopep8] PycodestyleBear (E128): E128 continuation line under-indented for visual indent" | ||
}, | ||
{ | ||
"severity": 2, | ||
"range": { | ||
"start": { | ||
"line": 2, | ||
"character": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"character": 0 | ||
} | ||
}, | ||
"source": "coala", | ||
"message": "[all.autopep8] PycodestyleBear (E901): E901 TokenError: EOF in multi-line statement" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import sys | ||
from os.path import join, dirname, abspath | ||
|
||
current = dirname(__file__) | ||
sys.path.append(join(current, 'helpers')) | ||
sys.path.append(abspath(join(current, '../../'))) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
class DummyFileProxy: | ||
|
||
def __init__(self, filename, workspace='.', content=''): | ||
self.filename = filename | ||
self.workspace = workspace | ||
self.content = content | ||
self.version = -1 | ||
|
||
|
||
class DummyFileProxyMap: | ||
|
||
def __init__(self, file_map={}): | ||
self.file_map = file_map | ||
|
||
def resolve(self, name): | ||
return self.file_map.get(name) | ||
|
||
|
||
class DummyDiagnostics: | ||
|
||
def __init__(self, warnings=[], fixes=[]): | ||
self.f_warnings = warnings | ||
self.f_fixes = fixes | ||
|
||
def warnings(self): | ||
return self.f_warnings | ||
|
||
|
||
class DummyFuture: | ||
|
||
def __init__(self, active=True, on_cancel=True, result=None): | ||
self.f_active = active | ||
self.f_result = result | ||
self.f_cancel = on_cancel | ||
self._cancelled = False | ||
|
||
def done(self): | ||
return not self.f_active | ||
|
||
def cancel(self): | ||
if self.f_cancel: | ||
self.f_active = False | ||
|
||
self._cancelled = True | ||
return self.f_cancel | ||
|
||
def cancelled(self): | ||
return self._cancelled | ||
|
||
def exception(self): | ||
return None | ||
|
||
def result(self): | ||
return self.f_result | ||
|
||
def add_done_callback(self, func): | ||
func(self) | ||
|
||
|
||
class DummyAlwaysCancelledFuture(DummyFuture): | ||
|
||
def __init__(self, active=True, on_cancel=True, result=None): | ||
DummyFuture.__init__(self, active, on_cancel, result) | ||
self._cancelled = True | ||
|
||
|
||
class DummyAlwaysExceptionFuture(DummyFuture): | ||
|
||
def exception(self): | ||
return Exception() | ||
|
||
|
||
class DummyProcessPoolExecutor: | ||
|
||
FutureClass = DummyFuture | ||
on_submit = None | ||
|
||
def __init__(self, max_workers=1, *args, **kargs): | ||
self._max_workers = max_workers | ||
|
||
def submit(self, func, *args, **kargs): | ||
self._func = lambda: func(*args, **kargs) | ||
result = self._func() | ||
|
||
if DummyProcessPoolExecutor.on_submit is None: | ||
return DummyProcessPoolExecutor.FutureClass(result=result) | ||
else: | ||
return DummyProcessPoolExecutor.on_submit | ||
|
||
def shutdown(self, *args, **kargs): | ||
self._closed = True | ||
return True | ||
|
||
|
||
class DummyLangServer: | ||
|
||
def __init__(self, rfile, wfile, *args, **kargs): | ||
self.f_rfile = rfile | ||
self.f_wfile = wfile | ||
self.started = False | ||
|
||
def start(self): | ||
self.started = True | ||
|
||
|
||
class DummyTCPServer: | ||
|
||
panic = False | ||
served = False | ||
closed = False | ||
keyboard_interrupt = False | ||
|
||
def __init__(self, *args, **kargs): | ||
if DummyTCPServer.panic: | ||
raise Exception() | ||
|
||
def serve_forever(self): | ||
DummyTCPServer.served = True | ||
if DummyTCPServer.keyboard_interrupt: | ||
raise KeyboardInterrupt() | ||
|
||
def server_close(self): | ||
DummyTCPServer.closed = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pathlib import Path | ||
|
||
# relative to the project directory | ||
base_relative_url = Path.cwd().joinpath( | ||
'tests', 'resources') | ||
|
||
|
||
def url(val, as_obj=False): | ||
names = val.split('|') | ||
path = base_relative_url.joinpath(*names) | ||
|
||
return path if as_obj else str(path) | ||
|
||
|
||
sample_diagnostics = url('diagnostics.json') | ||
|
||
sample_code_files = { | ||
url('failure.py'): { | ||
'diagnostics': 1, | ||
}, | ||
|
||
url('failure2.py'): { | ||
'diagnostics': 2, | ||
}, | ||
} | ||
|
||
|
||
def count_diagnostics(diagnostics): | ||
diagnostics_count = 0 | ||
for section, diags in diagnostics.items(): | ||
diagnostics_count += len(diags) | ||
|
||
return diagnostics_count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pathlib import Path | ||
|
||
|
||
def get_random_path(suffix, as_obj=False, py=True): | ||
ext = 'py' if py else 'txt' | ||
filename = 'coala-rox-{}.{}'.format(suffix, ext) | ||
path = Path.cwd().joinpath('coala-x-miss', filename) | ||
|
||
return path if as_obj else str(path) |
Oops, something went wrong.