Edward,

On Sun, Dec 29, 2019 at 2:03 PM Edward K. Ream <edream...@gmail.com> wrote:

> On Saturday, December 28, 2019 at 10:44:39 AM UTC-5, btheado wrote:
>
> I've been experimenting lately writing pytest tests for leo. I just
>> published my work at
>> https://github.com/btheado/leo-editor/tree/pytest-experiment.
>>
>
>> You should be able try it out with these commands (untested):
>>
>> git origin add btheado https://github.com/btheado/leo-editor.git
>> git checkout btheado pytest-experiment
>> pip install pytest
>> pytest leo/test/pytest
>>
>>
> The first line didn't work.  I did `git clone
> https://github.com/btheado/leo-editor.git brian`, but I don't see the
> pytest folder in the leo/test folder, which is strange.
>

Sorry about that. Not sure what is wrong with my instructions. Your clone
should work just as well. From the clone be sure you are on the
pytest-experiment branch (git checkout pytest-experiment). Did you already
try that and not find the leo/test/pytest folder? If that doesn't work, I'm
not sure what to say other than you can view the code at github:
https://github.com/btheado/leo-editor/tree/pytest-experiment/leo/test/pytest


> With my present setup,  `pytest leo\core\leoAst.py` executes all the
> present unit tests in leoAst.py:
>
> leo\core\leoAst.py
> .......................................................................
>
> ========================== 71 passed in 5.42 seconds
> ==========================
>
> So I don't understand what difference pytest makes.  What am I missing?
>

According to https://docs.pytest.org/en/latest/unittest.html#unittest,
pytest supports running unittest style tests. That page has a list of
purported benefits of using pytest even for unittest style tests. I haven't
used unittest to write tests, I only know I like the function-based style
which pytest encourages. As it says on the main page (
https://docs.pytest.org/en/latest/index.html): "The pytest framework makes
it easy to write small tests, yet scales to support complex functional
testing for applications and libraries."

You might need to introduce failed tests in order to experience the better
assert failure reporting?

You might also find the code coverage report useful:

pip install pytest-cov
pytest --cov-report html --cov-report term-missing --cov=leo.core.leoAst
leo/core/leoAst.py
firefox htmlcov/leo_core_leoAst_py.html



> Btw, giving a directory does *not* work (pytest 3.6.7).  For example,
> pytest leo\core finds no tests.
>

https://docs.pytest.org/en/latest/goodpractices.html#test-discovery - the
default test discovery for pytest will only find tests within test_*.py or
*_test.py files

3.6 is almost a year and a half old, I think. I only started using pytest
version 5.2+, so I'm not very familiar with old versions. Might be useful
for you to upgrade.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAO5X8CwhiAk3LYmy7jzg%3DRsQ_3CWmLJ-6Os0rxYgkh%2B%3DzJxnYw%40mail.gmail.com.

Reply via email to