diff --git a/ci/requirements.el b/ci/requirements.el index 44f3af7..4ef3ca7 100644 --- a/ci/requirements.el +++ b/ci/requirements.el @@ -29,7 +29,7 @@ (package-initialize) (package-refresh-contents) -(setq package-selected-packages '(f s projectile cl buttercup)) +(setq package-selected-packages '(s projectile cl buttercup)) (package-install-selected-packages) diff --git a/lisp/pytest-process.el b/lisp/pytest-process.el index b98958a..3a0d293 100644 --- a/lisp/pytest-process.el +++ b/lisp/pytest-process.el @@ -22,7 +22,6 @@ ;;; Code: (require 'projectile) -(require 'f) (require 's) (require 'pytest-core) @@ -41,7 +40,7 @@ to work in every virtual environment." (defun pytest--python () "Find the python executable." - (if (f-absolute? pytest-python-executable) + (if (file-name-absolute-p pytest-python-executable) pytest-python-executable (executable-find pytest-python-executable))) @@ -49,21 +48,27 @@ to work in every virtual environment." "Construct the base command for pytest." (cons (pytest--python) '("-m" "pytest"))) -(defun pytest--execute (name command dir output-buffer) +(defun pytest--execute (name command dir output-buffer &optional error-buffer) "Execute COMMAND asynchronously in DIR. NAME is a name for the process. -stdout is written to OUTPUT-BUFFER, which needs to be a buffer, not a string." +stdout is written to OUTPUT-BUFFER, which needs to be a buffer, not a string. +stderr is written to ERROR-BUFFER, which also needs to be a buffer." (let ((default-directory dir)) - (start-process-shell-command name output-buffer command))) + (make-process + :name name + :buffer output-buffer + :stderr error-buffer + :connection-type 'pipe + :command command))) (defun pytest--construct-command (args) "Construct the pytest command using ARGS." (let ((command (append (pytest--command) args))) (s-join " " command))) -(defun pytest--run (&optional args dir output-buffer) +(defun pytest--run (&optional args dir output-buffer error-buffer) "Run pytest with ARGS (if any) in the given DIR and write to OUTPUT-BUFFER. If optional ARGS is non-nil, these are passed to pytest. @@ -72,10 +77,11 @@ If optional DIR is non-nil, pytest is run in that directory. Otherwise it is run in the project's root as defined by projectile or the current working directory. -If optional OUTPUT-BUFFER is non-nil, write to that buffer." +If optional OUTPUT-BUFFER is non-nil, write stderr to that buffer. +If optional ERROR-BUFFER is non-nil, write stderr to that buffer." (let ((command (pytest--construct-command args)) (default-directory (or dir (projectile-project-root)))) - (pytest--execute "pytest" command default-directory output-buffer))) + (pytest--execute "pytest" command default-directory output-buffer error-buffer))) (provide 'pytest-process) ;;; pytest-process.el ends here diff --git a/test.log b/test.log new file mode 100644 index 0000000..3a0a1eb --- /dev/null +++ b/test.log @@ -0,0 +1,73 @@ +{"pytest_version": "6.2.2", "$report_type": "SessionStart"} +{"nodeid": "", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example1.py", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example2.py::TestGroup", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example2.py::TestGroup", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example2.py::GroupTest", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example2.py", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example3.py", "outcome": "skipped", "longrepr": ["/home/lugh/Documents/Programming/emacs/pytest/tests/test_example3.py", 4, "Skipped: could not import 'lkjasdf\u00f6lkja8723lkas98723_': No module named 'lkjasdf\u00f6lkja8723lkas98723_'"], "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example4.py", "outcome": "passed", "longrepr": null, "result": null, "sections": [], "$report_type": "CollectReport"} +{"nodeid": "tests/test_example1.py::test_pass", "location": ["tests/test_example1.py", 16, "test_pass"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00026758800231618807, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_pass", "location": ["tests/test_example1.py", 16, "test_pass"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.0003977960004704073, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_pass", "location": ["tests/test_example1.py", 16, "test_pass"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00033361899841111153, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_pass_with_output", "location": ["tests/test_example1.py", 21, "test_pass_with_output"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_pass_with_output": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00024384300195379183, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_pass_with_output", "location": ["tests/test_example1.py", 21, "test_pass_with_output"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_pass_with_output": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [["Captured stdout call", "output\n"], ["Captured stderr call", "error message\n"]], "duration": 0.0003927200014004484, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_pass_with_output", "location": ["tests/test_example1.py", 21, "test_pass_with_output"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_pass_with_output": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [["Captured stdout call", "output\n"], ["Captured stderr call", "error message\n"]], "duration": 0.0003037749993382022, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_fail", "location": ["tests/test_example1.py", 26, "test_fail"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_fail": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00026951699692290276, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_fail", "location": ["tests/test_example1.py", 26, "test_fail"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_fail": 1}, "outcome": "failed", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 29, "message": "assert False"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_fail():", " warn()", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 29, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_fail():", " warn()", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 29, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 29, "message": "assert False"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.00043938899761997163, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_fail", "location": ["tests/test_example1.py", 26, "test_fail"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_fail": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0004675329983001575, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_error", "location": ["tests/test_example1.py", 31, "test_error"], "keywords": {"test_error": 1, "tests/test_example1.py": 1, "pytest": 1}, "outcome": "failed", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 14, "message": "assert False"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.fixture", " def failing():", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 14, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.fixture", " def failing():", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 14, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 14, "message": "assert False"}, null]]}, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00037439900188473985, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_error", "location": ["tests/test_example1.py", 31, "test_error"], "keywords": {"test_error": 1, "tests/test_example1.py": 1, "pytest": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0004358430014690384, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xfail", "location": ["tests/test_example1.py", 35, "test_xfail"], "keywords": {"test_xfail": 1, "xfail": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00027707400295184925, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xfail", "location": ["tests/test_example1.py", 35, "test_xfail"], "keywords": {"test_xfail": 1, "xfail": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1}, "outcome": "skipped", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 40, "message": "assert False"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.mark.xfail", " def test_xfail():", " warn()", " ", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 40, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.mark.xfail", " def test_xfail():", " warn()", " ", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 40, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 40, "message": "assert False"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.0004169019957771525, "wasxfail": "", "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xfail", "location": ["tests/test_example1.py", 35, "test_xfail"], "keywords": {"test_xfail": 1, "xfail": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003892230015480891, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xfail_reason", "location": ["tests/test_example1.py", 42, "test_xfail_reason"], "keywords": {"xfail": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1, "test_xfail_reason": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0002377780037932098, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xfail_reason", "location": ["tests/test_example1.py", 42, "test_xfail_reason"], "keywords": {"xfail": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1, "test_xfail_reason": 1}, "outcome": "skipped", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 45, "message": "assert False"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.mark.xfail(reason=\"xfail without a reason\")", " def test_xfail_reason():", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 45, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.mark.xfail(reason=\"xfail without a reason\")", " def test_xfail_reason():", "> assert False", "E assert False"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 45, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 45, "message": "assert False"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.00037447399517986923, "wasxfail": "xfail without a reason", "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xfail_reason", "location": ["tests/test_example1.py", 42, "test_xfail_reason"], "keywords": {"xfail": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1, "test_xfail_reason": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003786629968089983, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xpass", "location": ["tests/test_example1.py", 47, "test_xpass"], "keywords": {"xfail": 1, "test_xpass": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00023435999901266769, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xpass", "location": ["tests/test_example1.py", 47, "test_xpass"], "keywords": {"xfail": 1, "test_xpass": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.0003204929962521419, "wasxfail": "", "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_xpass", "location": ["tests/test_example1.py", 47, "test_xpass"], "keywords": {"xfail": 1, "test_xpass": 1, "pytest": 1, "pytestmark": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003025210025953129, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_skip", "location": ["tests/test_example1.py", 53, "test_skip"], "keywords": {"skipif": 1, "tests/test_example1.py": 1, "pytest": 1, "pytestmark": 1, "test_skip": 1}, "outcome": "skipped", "longrepr": ["/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", 54, "Skipped: skipping the test without a reason for testing purposes"], "when": "setup", "user_properties": [], "sections": [], "duration": 0.00020535500516416505, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_skip", "location": ["tests/test_example1.py", 53, "test_skip"], "keywords": {"skipif": 1, "tests/test_example1.py": 1, "pytest": 1, "pytestmark": 1, "test_skip": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00025266699958592653, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[0]", "location": ["tests/test_example1.py", 78, "test_variations[0]"], "keywords": {"0": 1, "tests/test_example1.py": 1, "pytest": 1, "test_variations[0]": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00035399599437369034, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[0]", "location": ["tests/test_example1.py", 78, "test_variations[0]"], "keywords": {"0": 1, "tests/test_example1.py": 1, "pytest": 1, "test_variations[0]": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.00030381899705389515, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[0]", "location": ["tests/test_example1.py", 78, "test_variations[0]"], "keywords": {"0": 1, "tests/test_example1.py": 1, "pytest": 1, "test_variations[0]": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00036429699684958905, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[1]", "location": ["tests/test_example1.py", 78, "test_variations[1]"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "1": 1, "test_variations[1]": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0003599519986892119, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[1]", "location": ["tests/test_example1.py", 78, "test_variations[1]"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "1": 1, "test_variations[1]": 1}, "outcome": "failed", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 80, "message": "assert False\n + where False = example(1)"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_variations(variable):", "> assert example(variable)", "E assert False", "E + where False = example(1)"], "reprfuncargs": {"args": [["variable", "1"]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 80, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_variations(variable):", "> assert example(variable)", "E assert False", "E + where False = example(1)"], "reprfuncargs": {"args": [["variable", "1"]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 80, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 80, "message": "assert False\n + where False = example(1)"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.0004271489960956387, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[1]", "location": ["tests/test_example1.py", 78, "test_variations[1]"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "1": 1, "test_variations[1]": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00043593499867711216, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[2]", "location": ["tests/test_example1.py", 78, "test_variations[2]"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "2": 1, "test_variations[2]": 1}, "outcome": "failed", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 75, "message": "AssertionError: assert 2 != 2\n + where 2 = >.param"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.fixture(", " params=[", " pytest.param(0),", " pytest.param(1),", " pytest.param(2),", " pytest.param(3, marks=pytest.mark.xfail),", " pytest.param(4, marks=pytest.mark.xfail),", " pytest.param(5, marks=pytest.mark.skip),", " ]", " )", " @pytest.mark.xfail", " @pytest.mark.skip", " def variable(request):", "> assert request.param != 2", "E AssertionError: assert 2 != 2", "E + where 2 = >.param"], "reprfuncargs": {"args": [["request", ">"]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 75, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.fixture(", " params=[", " pytest.param(0),", " pytest.param(1),", " pytest.param(2),", " pytest.param(3, marks=pytest.mark.xfail),", " pytest.param(4, marks=pytest.mark.xfail),", " pytest.param(5, marks=pytest.mark.skip),", " ]", " )", " @pytest.mark.xfail", " @pytest.mark.skip", " def variable(request):", "> assert request.param != 2", "E AssertionError: assert 2 != 2", "E + where 2 = >.param"], "reprfuncargs": {"args": [["request", ">"]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 75, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 75, "message": "AssertionError: assert 2 != 2\n + where 2 = >.param"}, null]]}, "when": "setup", "user_properties": [], "sections": [], "duration": 0.000488559999212157, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[2]", "location": ["tests/test_example1.py", 78, "test_variations[2]"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "2": 1, "test_variations[2]": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00042178400326520205, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[3]", "location": ["tests/test_example1.py", 78, "test_variations[3]"], "keywords": {"test_variations[3]": 1, "xfail": 1, "3": 1, "pytest": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00035261199809610844, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[3]", "location": ["tests/test_example1.py", 78, "test_variations[3]"], "keywords": {"test_variations[3]": 1, "xfail": 1, "3": 1, "pytest": 1, "tests/test_example1.py": 1}, "outcome": "skipped", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 80, "message": "assert False\n + where False = example(3)"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_variations(variable):", "> assert example(variable)", "E assert False", "E + where False = example(3)"], "reprfuncargs": {"args": [["variable", "3"]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 80, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_variations(variable):", "> assert example(variable)", "E assert False", "E + where False = example(3)"], "reprfuncargs": {"args": [["variable", "3"]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example1.py", "lineno": 80, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", "lineno": 80, "message": "assert False\n + where False = example(3)"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.0004110809968551621, "wasxfail": "", "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[3]", "location": ["tests/test_example1.py", 78, "test_variations[3]"], "keywords": {"test_variations[3]": 1, "xfail": 1, "3": 1, "pytest": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0004417510062921792, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[4]", "location": ["tests/test_example1.py", 78, "test_variations[4]"], "keywords": {"test_variations[4]": 1, "4": 1, "xfail": 1, "pytest": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00034788699849741533, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[4]", "location": ["tests/test_example1.py", 78, "test_variations[4]"], "keywords": {"test_variations[4]": 1, "4": 1, "xfail": 1, "pytest": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.00028570100403157994, "wasxfail": "", "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[4]", "location": ["tests/test_example1.py", 78, "test_variations[4]"], "keywords": {"test_variations[4]": 1, "4": 1, "xfail": 1, "pytest": 1, "tests/test_example1.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00034982000215677544, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[5]", "location": ["tests/test_example1.py", 78, "test_variations[5]"], "keywords": {"pytest": 1, "5": 1, "test_variations[5]": 1, "tests/test_example1.py": 1, "skip": 1}, "outcome": "skipped", "longrepr": ["/home/lugh/Documents/Programming/emacs/pytest/tests/test_example1.py", 79, "Skipped: unconditional skip"], "when": "setup", "user_properties": [], "sections": [], "duration": 0.0002231719990959391, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_variations[5]", "location": ["tests/test_example1.py", 78, "test_variations[5]"], "keywords": {"pytest": 1, "5": 1, "test_variations[5]": 1, "tests/test_example1.py": 1, "skip": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0002498499961802736, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_nested", "location": ["tests/test_example1.py", 82, "test_nested"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_nested": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0002262639973196201, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_nested", "location": ["tests/test_example1.py", 82, "test_nested"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_nested": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.0003070620005019009, "$report_type": "TestReport"} +{"nodeid": "tests/test_example1.py::test_nested", "location": ["tests/test_example1.py", 82, "test_nested"], "keywords": {"tests/test_example1.py": 1, "pytest": 1, "test_nested": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003040730007342063, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::test_case", "location": ["tests/test_example2.py", 4, "test_case"], "keywords": {"test_case": 1, "pytest": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0002549999990151264, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::test_case", "location": ["tests/test_example2.py", 4, "test_case"], "keywords": {"test_case": 1, "pytest": 1, "tests/test_example2.py": 1}, "outcome": "failed", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", "lineno": 6, "message": "ValueError: always fails"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_case():", "> raise ValueError(\"always fails\")", "E ValueError: always fails"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example2.py", "lineno": 6, "message": "ValueError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_case():", "> raise ValueError(\"always fails\")", "E ValueError: always fails"], "reprfuncargs": {"args": []}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example2.py", "lineno": 6, "message": "ValueError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", "lineno": 6, "message": "ValueError: always fails"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.0003349580001668073, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::test_case", "location": ["tests/test_example2.py", 4, "test_case"], "keywords": {"test_case": 1, "pytest": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003770219991565682, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_pass", "location": ["tests/test_example2.py", 12, "TestGroup.test_pass"], "keywords": {"skipif": 1, "()": 1, "pytest": 1, "TestGroup": 1, "tests/test_example2.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00023950300237629563, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_pass", "location": ["tests/test_example2.py", 12, "TestGroup.test_pass"], "keywords": {"skipif": 1, "()": 1, "pytest": 1, "TestGroup": 1, "tests/test_example2.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.0003564610015018843, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_pass", "location": ["tests/test_example2.py", 12, "TestGroup.test_pass"], "keywords": {"skipif": 1, "()": 1, "pytest": 1, "TestGroup": 1, "tests/test_example2.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00030535700352629647, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_skip", "location": ["tests/test_example2.py", 15, "TestGroup.test_skip"], "keywords": {"skipif": 1, "tests/test_example2.py": 1, "()": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "test_skip": 1, "skip": 1}, "outcome": "skipped", "longrepr": ["/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", 16, "Skipped: a long and elaborate, multi-line reason on why this test has to fail"], "when": "setup", "user_properties": [], "sections": [], "duration": 0.00020762799977092072, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_skip", "location": ["tests/test_example2.py", 15, "TestGroup.test_skip"], "keywords": {"skipif": 1, "tests/test_example2.py": 1, "()": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "test_skip": 1, "skip": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0002627140056574717, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_xfail", "location": ["tests/test_example2.py", 21, "TestGroup.test_xfail"], "keywords": {"skipif": 1, "test_xfail": 1, "()": 1, "xfail": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0002486610028427094, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_xfail", "location": ["tests/test_example2.py", 21, "TestGroup.test_xfail"], "keywords": {"skipif": 1, "test_xfail": 1, "()": 1, "xfail": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "tests/test_example2.py": 1}, "outcome": "skipped", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", "lineno": 24, "message": "assert False"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.mark.xfail", " def test_xfail(self):", "> assert False", "E assert False"], "reprfuncargs": {"args": [["self", ""]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example2.py", "lineno": 24, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" @pytest.mark.xfail", " def test_xfail(self):", "> assert False", "E assert False"], "reprfuncargs": {"args": [["self", ""]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example2.py", "lineno": 24, "message": "AssertionError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", "lineno": 24, "message": "assert False"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.0003810960042756051, "wasxfail": "", "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_xfail", "location": ["tests/test_example2.py", 21, "TestGroup.test_xfail"], "keywords": {"skipif": 1, "test_xfail": 1, "()": 1, "xfail": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003728500014403835, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_xpass", "location": ["tests/test_example2.py", 25, "TestGroup.test_xpass"], "keywords": {"skipif": 1, "()": 1, "xfail": 1, "test_xpass": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0002467360027367249, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_xpass", "location": ["tests/test_example2.py", 25, "TestGroup.test_xpass"], "keywords": {"skipif": 1, "()": 1, "xfail": 1, "test_xpass": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.0002949530025944114, "wasxfail": "", "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::TestGroup::test_xpass", "location": ["tests/test_example2.py", 25, "TestGroup.test_xpass"], "keywords": {"skipif": 1, "()": 1, "xfail": 1, "test_xpass": 1, "pytest": 1, "pytestmark": 1, "TestGroup": 1, "tests/test_example2.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0003431719960644841, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::GroupTest::test_fail", "location": ["tests/test_example2.py", 34, "GroupTest.test_fail"], "keywords": {"GroupTest": 1, "tests/test_example2.py": 1, "pytest": 1, "test_fail": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.0004810719983652234, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::GroupTest::test_fail", "location": ["tests/test_example2.py", 34, "GroupTest.test_fail"], "keywords": {"GroupTest": 1, "tests/test_example2.py": 1, "pytest": 1, "test_fail": 1}, "outcome": "failed", "longrepr": {"reprcrash": {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", "lineno": 36, "message": "ValueError: always fails"}, "reprtraceback": {"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_fail(self):", "> raise ValueError(\"always fails\")", "E ValueError: always fails"], "reprfuncargs": {"args": [["self", ""]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example2.py", "lineno": 36, "message": "ValueError"}, "style": "long"}}], "extraline": null, "style": "long"}, "sections": [], "chain": [[{"reprentries": [{"type": "ReprEntry", "data": {"lines": [" def test_fail(self):", "> raise ValueError(\"always fails\")", "E ValueError: always fails"], "reprfuncargs": {"args": [["self", ""]]}, "reprlocals": null, "reprfileloc": {"path": "tests/test_example2.py", "lineno": 36, "message": "ValueError"}, "style": "long"}}], "extraline": null, "style": "long"}, {"path": "/home/lugh/Documents/Programming/emacs/pytest/tests/test_example2.py", "lineno": 36, "message": "ValueError: always fails"}, null]]}, "when": "call", "user_properties": [], "sections": [], "duration": 0.0004581339962896891, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::GroupTest::test_fail", "location": ["tests/test_example2.py", 34, "GroupTest.test_fail"], "keywords": {"GroupTest": 1, "tests/test_example2.py": 1, "pytest": 1, "test_fail": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.00036222999915480614, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::GroupTest::test_pass", "location": ["tests/test_example2.py", 31, "GroupTest.test_pass"], "keywords": {"GroupTest": 1, "pytest": 1, "tests/test_example2.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "setup", "user_properties": [], "sections": [], "duration": 0.00042721800127765164, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::GroupTest::test_pass", "location": ["tests/test_example2.py", 31, "GroupTest.test_pass"], "keywords": {"GroupTest": 1, "pytest": 1, "tests/test_example2.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "call", "user_properties": [], "sections": [], "duration": 0.0015028600028017536, "$report_type": "TestReport"} +{"nodeid": "tests/test_example2.py::GroupTest::test_pass", "location": ["tests/test_example2.py", 31, "GroupTest.test_pass"], "keywords": {"GroupTest": 1, "pytest": 1, "tests/test_example2.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0007173850026447326, "$report_type": "TestReport"} +{"nodeid": "tests/test_example4.py::test_pass", "location": ["tests/test_example4.py", 5, "test_pass"], "keywords": {"skipif": 1, "pytest": 1, "tests/test_example4.py": 1, "test_pass": 1}, "outcome": "skipped", "longrepr": ["/home/lugh/Documents/Programming/emacs/pytest/tests/test_example4.py", 6, "Skipped: skip for demonstration purposes"], "when": "setup", "user_properties": [], "sections": [], "duration": 0.00022610400628764182, "$report_type": "TestReport"} +{"nodeid": "tests/test_example4.py::test_pass", "location": ["tests/test_example4.py", 5, "test_pass"], "keywords": {"skipif": 1, "pytest": 1, "tests/test_example4.py": 1, "test_pass": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0002561799992690794, "$report_type": "TestReport"} +{"exitstatus": 1, "$report_type": "SessionFinish"} diff --git a/tests/test-info.el b/tests/test-info.el index 867774c..7792a3a 100644 --- a/tests/test-info.el +++ b/tests/test-info.el @@ -75,7 +75,7 @@ (describe "a function to check if the current statement is a decorator (pytest-info--decorator-p)" (it "detects the first line of a decorator" - (expect (with-mark-at-line buffer1 12 (pytest-info--decorator-p)) :to-be t)) + (expect (with-mark-at-line buffer1 13 (pytest-info--decorator-p)) :to-be t)) (it "detects continuation lines of a decorator" (expect (with-mark-at-line buffer1 44 (pytest-info--decorator-p)) :to-be t)) @@ -87,36 +87,35 @@ (expect (with-mark-at-line buffer2 19 (pytest-info--decorator-p)) :to-be t)) (it "does not detect function declarations" - (expect (with-mark-at-line buffer1 13 (pytest-info--decorator-p)) :to-be nil)) + (expect (with-mark-at-line buffer1 14 (pytest-info--decorator-p)) :to-be nil)) (it "does not detect normal statements" (expect (with-mark-at-line buffer1 23 (pytest-info--decorator-p)) :to-be nil))) (describe "a function to collect information about the current position (pytest-info-current-pos)" (it "does not collect information about a empty line at module level" - (expect (with-mark-at-line buffer1 5 (pytest-info-current-pos)) + (expect (with-mark-at-line buffer1 7 (pytest-info-current-pos)) :to-equal nil)) (it "detects a plain function" - (expect (with-mark-at-line buffer1 8 (pytest-info-current-pos)) + (expect (with-mark-at-line buffer1 9 (pytest-info-current-pos)) :to-equal (list filepath1 "warn")) - (expect (with-mark-at-line buffer1 8 (pytest-info-current-pos)) + (expect (with-mark-at-line buffer1 10 (pytest-info-current-pos)) :to-equal (list filepath1 "warn"))) (it "detects a function with a decorator" - (expect (with-mark-at-line buffer1 12 (pytest-info-current-pos)) + (expect (with-mark-at-line buffer1 13 (pytest-info-current-pos)) :to-equal (list filepath1 "failing")) - (expect (with-mark-at-line buffer1 44 (pytest-info-current-pos)) + (expect (with-mark-at-line buffer1 51 (pytest-info-current-pos)) :to-equal (list filepath1 "test_skip"))) (it "detects a function with multiple decorators" (expect (with-mark-at-line buffer1 62 (pytest-info-current-pos)) :to-equal (list filepath1 "variable")) (expect (with-mark-at-line buffer1 59 (pytest-info-current-pos)) :to-equal (list filepath1 "variable")) - (expect (with-mark-at-line buffer1 52 (pytest-info-current-pos)) + (expect (with-mark-at-line buffer1 68 (pytest-info-current-pos)) :to-equal (list filepath1 "variable"))) (it "detects a function from within the function's body" (expect (with-mark-at-line buffer1 34 (pytest-info-current-pos)) :to-equal (list filepath1 "test_xfail"))))) - (provide 'test-info) ;;; test-info.el ends here diff --git a/tests/test_example1.py b/tests/test_example1.py index 6f00224..c1c0271 100644 --- a/tests/test_example1.py +++ b/tests/test_example1.py @@ -1,3 +1,4 @@ +import sys import warnings import pytest @@ -35,6 +36,11 @@ def test_xfail(): assert False +@pytest.mark.xfail(reason="xfail without a reason") +def test_xfail_reason(): + assert False + + @pytest.mark.xfail def test_xpass(): warn() @@ -84,3 +90,8 @@ def test_long_running(): import time time.sleep(2) + + +def test_pass_with_output(): + print("output") + print("error message", file=sys.stderr) diff --git a/tests/test_example3.py b/tests/test_example3.py new file mode 100644 index 0000000..b644abe --- /dev/null +++ b/tests/test_example3.py @@ -0,0 +1,3 @@ +import pytest + +important_module = pytest.importorskip("lkjasdfölkja8723lkas98723_") diff --git a/tests/test_example4.py b/tests/test_example4.py new file mode 100644 index 0000000..cd6e7e4 --- /dev/null +++ b/tests/test_example4.py @@ -0,0 +1,7 @@ +import pytest + +pytestmark = [pytest.mark.skipif(True, reason="skip for demonstration purposes")] + + +def test_pass(): + pass