Skip to content

Testing tools adapter py2 #4646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/ci/templates/compile-and-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
arguments: '-m pip install --upgrade -r ./build/test-requirements.txt'


- bash: 'python -m pythonFiles.tests'
- bash: 'python pythonFiles/tests/run_all.py'
displayName: 'run pythonFiles unit tests'


Expand Down
Empty file.
6 changes: 4 additions & 2 deletions pythonFiles/testing_tools/adapter/errors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

class UnsupportedToolError(ValueError):
def __init__(self, tool):
super().__init__('unsupported tool {!r}'.format(tool))
msg = 'unsupported tool {!r}'.format(tool)
super(UnsupportedToolError, self).__init__(msg)
self.tool = tool


class UnsupportedCommandError(ValueError):
def __init__(self, cmd):
super().__init__('unsupported cmd {!r}'.format(cmd))
msg = 'unsupported cmd {!r}'.format(cmd)
super(UnsupportedCommandError, self).__init__(msg)
self.cmd = cmd
2 changes: 2 additions & 0 deletions pythonFiles/testing_tools/adapter/pytest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import absolute_import

import os.path

import pytest
Expand Down
4 changes: 3 additions & 1 deletion pythonFiles/testing_tools/adapter/report.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import print_function

import json


def report_discovered(tests, debug=False,
_send=print):
_send=print):
"""Serialize the discovered tests and write to stdout."""
data = [{
'id': test.id,
Expand Down
9 changes: 7 additions & 2 deletions pythonFiles/tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
TESTING_TOOLS_ROOT = os.path.join(SRC_ROOT, 'testing_tools')


if __name__ == '__main__':
def main(argv=sys.argv[1:]):
sys.path.insert(1, DATASCIENCE_ROOT)
sys.path.insert(1, TESTING_TOOLS_ROOT)
ec = pytest.main([
'--rootdir', SRC_ROOT,
TEST_ROOT,
] + sys.argv[1:])
] + argv)
return ec


if __name__ == '__main__':
ec = main()
sys.exit(ec)
13 changes: 13 additions & 0 deletions pythonFiles/tests/run_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Replace the "." entry.
import os.path
import sys
sys.path[0] = os.path.dirname(
os.path.dirname(
os.path.abspath(__file__)))

from tests.__main__ import main


if __name__ == '__main__':
ec = main()
sys.exit(ec)
4 changes: 2 additions & 2 deletions pythonFiles/tests/testing_tools/adapter/test___main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class StubTool(StubProxy):

def __init__(self, name, stub=None):
super().__init__(stub, name)
super(StubTool, self).__init__(stub, name)
self.return_discover = None

def discover(self, args, **kwargs):
Expand All @@ -22,7 +22,7 @@ def discover(self, args, **kwargs):
class StubReporter(StubProxy):

def __init__(self, stub=None):
super().__init__(stub, 'reporter')
super(StubReporter, self).__init__(stub, 'reporter')

def report(self, discovered, **kwargs):
self.add_call('report', (discovered,), kwargs or None)
Expand Down
14 changes: 7 additions & 7 deletions pythonFiles/tests/testing_tools/adapter/test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class StubSubparsers(StubProxy):

def __init__(self, stub=None, name='subparsers'):
super().__init__(stub, name)
super(StubSubparsers, self).__init__(stub, name)

def add_parser(self, name):
self.add_call('add_parser', None, {'name': name})
Expand All @@ -22,7 +22,7 @@ def add_parser(self, name):
class StubArgParser(StubProxy):

def __init__(self, stub=None):
super().__init__(stub, 'argparser')
super(StubArgParser, self).__init__(stub, 'argparser')

def add_argument(self, *args, **kwargs):
self.add_call('add_argument', args, kwargs)
Expand All @@ -31,7 +31,7 @@ def add_argument(self, *args, **kwargs):
class StubPyTest(StubProxy):

def __init__(self, stub=None):
super().__init__(stub, 'pytest')
super(StubPyTest, self).__init__(stub, 'pytest')
self.return_main = 0

def main(self, args, plugins):
Expand All @@ -42,7 +42,7 @@ def main(self, args, plugins):
class StubPlugin(StubProxy):

def __init__(self, stub=None):
super().__init__(stub, 'plugin')
super(StubPlugin, self).__init__(stub, 'plugin')

def __getattr__(self, name):
if not name.startswith('pytest_'):
Expand All @@ -67,7 +67,7 @@ def __init__(self, name):
class StubPytestItem(StubProxy):

def __init__(self, stub=None, **attrs):
super().__init__(stub, 'pytest.Item')
super(StubPytestItem, self).__init__(stub, 'pytest.Item')
self.__dict__.update(attrs)
if 'own_markers' not in attrs:
self.own_markers = ()
Expand All @@ -82,7 +82,7 @@ def func(*args, **kwargs):
class StubPytestSession(StubProxy):

def __init__(self, stub=None):
super().__init__(stub, 'pytest.Session')
super(StubPytestSession, self).__init__(stub, 'pytest.Session')

def __getattr__(self, name):
self.add_call(name + ' (attr)', None, None)
Expand All @@ -94,7 +94,7 @@ def func(*args, **kwargs):
class StubPytestConfig(StubProxy):

def __init__(self, stub=None):
super().__init__(stub, 'pytest.Config')
super(StubPytestConfig, self).__init__(stub, 'pytest.Config')

def __getattr__(self, name):
self.add_call(name + ' (attr)', None, None)
Expand Down