mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1417920 - [python-test] Use a global pytest.ini configuration file, r=davehunt
This changes two config options: pytest_classes = PyTest # only classes that start with 'PyTest' will be considered tests (previously this was Test) xfail_strict = true # tests marked as xfail will cause pytest to return non-zero if they unexpectedly pass MozReview-Commit-ID: DCWoDFbe6Mk --HG-- extra : rebase_source : 9aa806e035d62d51bb338708396851c40f55ee00
This commit is contained in:
parent
1a5f8dc284
commit
d19095947f
@ -12,6 +12,8 @@ from unittest import TextTestRunner as _TestRunner, TestResult as _TestResult
|
|||||||
import pytest
|
import pytest
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
StringIO = six.StringIO
|
StringIO = six.StringIO
|
||||||
|
|
||||||
'''Helper to make python unit tests report the way that the Mozilla
|
'''Helper to make python unit tests report the way that the Mozilla
|
||||||
@ -232,6 +234,7 @@ def main(*args, **kwargs):
|
|||||||
|
|
||||||
module = __import__('__main__')
|
module = __import__('__main__')
|
||||||
args.extend([
|
args.extend([
|
||||||
|
'-c', os.path.join(here, 'pytest.ini'),
|
||||||
'-vv',
|
'-vv',
|
||||||
'-p', 'mozlog.pytest_mozlog.plugin',
|
'-p', 'mozlog.pytest_mozlog.plugin',
|
||||||
'-p', 'no:cacheprovider',
|
'-p', 'no:cacheprovider',
|
||||||
|
3
config/mozunit/mozunit/pytest.ini
Normal file
3
config/mozunit/mozunit/pytest.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[pytest]
|
||||||
|
python_classes=PyTest
|
||||||
|
xfail_strict=true
|
@ -1,2 +0,0 @@
|
|||||||
[pytest]
|
|
||||||
addopts = -p no:terminalreporter
|
|
@ -89,4 +89,4 @@ def test_handler(server):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
mozunit.main('--log-tbpl=-')
|
mozunit.main('-p', 'no:terminalreporter', '--log-tbpl=-')
|
||||||
|
@ -66,4 +66,4 @@ def test_parse_opt_args_emulator(mach_parsed_kwargs, arg_name, arg_dest, arg_val
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mozunit.main('--log-tbpl=-')
|
mozunit.main('-p', 'no:terminalreporter', '--log-tbpl=-')
|
||||||
|
@ -107,4 +107,4 @@ def test_harness_sets_up_default_test_handlers(mach_parsed_kwargs):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mozunit.main('--log-tbpl=-')
|
mozunit.main('-p', 'no:terminalreporter', '--log-tbpl=-')
|
||||||
|
@ -507,4 +507,4 @@ def test_option_run_until_failure(mach_parsed_kwargs, repeat, run_until_failure)
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mozunit.main('--log-tbpl=-')
|
mozunit.main('-p', 'no:terminalreporter', '--log-tbpl=-')
|
||||||
|
@ -53,4 +53,4 @@ def test_crash_is_recorded_as_error(empty_marionette_test,
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mozunit.main('--log-tbpl=-')
|
mozunit.main('-p', 'no:terminalreporter', '--log-tbpl=-')
|
||||||
|
@ -66,4 +66,4 @@ def test_where_is():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
mozunit.main('--log-tbpl=-')
|
mozunit.main('-p', 'no:terminalreporter', '--log-tbpl=-')
|
||||||
|
@ -67,14 +67,13 @@ foo = ['A list of strings', 'that go over 80 characters', 'to test if autopep8 f
|
|||||||
assert fh.read() == contents
|
assert fh.read() == contents
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(
|
@pytest.mark.xfail(reason="Bug 1277851 - custom configs are ignored if specifying a parent path")
|
||||||
strict=True, reason="Bug 1277851 - custom configs are ignored if specifying a parent path")
|
|
||||||
def test_lint_custom_config_from_parent_path(lint, paths):
|
def test_lint_custom_config_from_parent_path(lint, paths):
|
||||||
results = lint(paths(), collapse_results=True)
|
results = lint(paths(), collapse_results=True)
|
||||||
assert paths('custom/good.py')[0] not in results
|
assert paths('custom/good.py')[0] not in results
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(strict=True, reason="Bug 1277851 - 'exclude' argument is ignored")
|
@pytest.mark.xfail(reason="Bug 1277851 - 'exclude' argument is ignored")
|
||||||
def test_lint_excluded_file(lint, paths):
|
def test_lint_excluded_file(lint, paths):
|
||||||
paths = paths('bad.py')
|
paths = paths('bad.py')
|
||||||
results = lint(paths, exclude=paths)
|
results = lint(paths, exclude=paths)
|
||||||
|
Loading…
Reference in New Issue
Block a user