def add_2(x):
return x + 2
def times_3(x):
return x * 3
def inc(x):
return x + 1
def test_a():
assert inc(3) == 4.1
def test_b():
assert times_3(add_2(inc(3.1))) == times_3(inc(5))
----------Failure-------------
assert 4 == 4.1
+ where 4 = inc(3)
----------Failure-------------
assert 18.299999999999997 == 18
+ where 18.299999999999997 = times_3(6.1)
+ where 6.1 = add_2(4.1)
+ where 4.1 = inc(3.1)
+ and 18 = times_3(6)
+ where 6 = inc(5)
failed:2 tests-------example/test_a failed---------
assert 4 == 4.1
+ where 4 = inc(3)
-------example/test_b failed---------
assert 18.299999999999997 == 18
+ where 18.299999999999997 = times_3(6.1)
+ where 6.1 = add_2(4.1)
+ where 4.1 = inc(3.1)
+ and 18 = times_3(6)
+ where 6 = inc(5)
failed:2 testsVitalije
Two days ago I've added to Leo a new command 'execute-pytest' which runs like `run-selected-unit-tests-locally`, but executes test functions in @test nodes as if they were in a file processed by pytest.
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/b7880eb4-9c2f-4d37-932d-d1f0d72fcfe3%40googlegroups.com.
This example code shows how tests can be collected from a yaml file instead of python code: https://docs.pytest.org/en/latest/example/nonpython.html#yaml-plugin. Writing code to get tests from unittest.leo might be similarly straightforward.That's quite an impressive plugin system pytest has.
Traceback (most recent call last):
File "/home/btheado/src/leo-editor/leo/core/leoGlobals.py", line 293, in new_cmd_wrapper
func(self, event=event)
File "/home/btheado/src/leo-editor/leo/core/leoCommands.py", line 729, in execute_pytest
self.execute_single_pytest(p)
File "/home/btheado/src/leo-editor/leo/core/leoCommands.py", line 761, in execute_single_pytest
rewrite_asserts(tree, script, config=cfg)
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 327, in rewrite_asserts
AssertionRewriter(module_path, config, source).run(mod)
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 572, in __init__
"enable_assertion_pass_hook"
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/config/__init__.py", line 976, in getini
self._inicache[name] = val = self._getini(name)
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/config/__init__.py", line 987, in _getini
value = self.inicfg[name]
AttributeError: 'Config' object has no attribute 'inicfg'
--
Vitalije,I was looking at the execute-pytest code and it looked to me like only the assertion rewrite functionality from pytest is being used. I would guess none of the hooks or fixtures and maybe most plugins will work.
I don't much trust my code reading so I figured I'd better test it, but I only got a stack trace when trying with your example:Traceback (most recent call last):
File "/home/btheado/src/leo-editor/leo/core/leoGlobals.py", line 293, in new_cmd_wrapper
func(self, event=event)
File "/home/btheado/src/leo-editor/leo/core/leoCommands.py", line 729, in execute_pytest
self.execute_single_pytest(p)
File "/home/btheado/src/leo-editor/leo/core/leoCommands.py", line 761, in execute_single_pytest
rewrite_asserts(tree, script, config=cfg)
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 327, in rewrite_asserts
AssertionRewriter(module_path, config, source).run(mod)
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 572, in __init__
"enable_assertion_pass_hook"
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/config/__init__.py", line 976, in getini
self._inicache[name] = val = self._getini(name)
File "/home/btheado/src/pyqt-3.7-venv/lib/python3.7/site-packages/_pytest/config/__init__.py", line 987, in _getini
value = self.inicfg[name]
AttributeError: 'Config' object has no attribute 'inicfg'python 3.7.3 and pytest 5.2.0Do you have any ideas?