emilybache / pytest-approvaltests

Plugin to configure pytest for use with approval tests
MIT License
5 stars 5 forks source link

PythonNative results in "This machine has no reporter configuration" #3

Open marcdexet-cnrs opened 2 years ago

marcdexet-cnrs commented 2 years ago

Hi,

I have

Python 3.8.10
approvaltests==4.1.0
pytest==7.1.1
pytest-approvaltests==0.2.3
Ubuntu 20.4

When I run pytest with pytest --approvaltests-use-reporter='PythonNative' -vv I get an error

================================================================================================================================================================== FAILURES ===================================================================================================================================================================
______________________________________________________________________________________________________________________________________________________________ test_change_name _______________________________________________________________________________________________________________________________________________________________

    def test_change_name():
        p = Person('Foo', 'BAR', Sex.female, 42)
        p.forname = 'Rosetta'
>       verify(p)

tests/test_person.py:14: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.8/site-packages/approvaltests/file_approver.py:53: in verify
    ok = self.verify_files(approved, received, reporter,comparator)
.venv/lib/python3.8/site-packages/approvaltests/file_approver.py:70: in verify_files
    worked = reporter.report(received_file, approved_file)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <approvaltests.reporters.generic_diff_reporter_factory.NoConfigReporter object at 0x7f1bc85532b0>, received_path = '/home/cram/Workdir/temporary_projects/approvals/tests/test_person.test_change_name.received.txt', approved_path = '/home/cram/Workdir/temporary_projects/approvals/tests/test_person.test_change_name.approved.txt'

    def report(self, received_path: str, approved_path: str) -> bool:
>       raise RuntimeError("This machine has no reporter configuration")
E       RuntimeError: This machine has no reporter configuration

.venv/lib/python3.8/site-packages/approvaltests/reporters/generic_diff_reporter_factory.py:16: RuntimeError
=========================================================================================================================================================== short test summary info ===========================================================================================================================================================
FAILED tests/test_person.py::test_change_name - RuntimeError: This machine has no reporter configuration
========================================================================================================================================================= 1 failed, 1 passed in 0.13s =========================================================================================================================================================

If I run with diff, there's no problem

============================================================================================================================================================= test session starts =============================================================================================================================================================
platform linux -- Python 3.8.10, pytest-7.1.1, pluggy-1.0.0 -- /home/cram/Workdir/temporary_projects/approvals/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/cram/Workdir/temporary_projects/approvals
plugins: approvaltests-0.2.3
collected 2 items                                                                                                                                                                                                                                                                                                                             

tests/test_person.py::test_one_person PASSED                                                                                                                                                                                                                                                                                            [ 50%]
tests/test_person.py::test_change_name FAILED                                                                                                                                                                                                                                                                                           [100%]

================================================================================================================================================================== FAILURES ===================================================================================================================================================================
______________________________________________________________________________________________________________________________________________________________ test_change_name _______________________________________________________________________________________________________________________________________________________________

    def test_change_name():
        p = Person('Foo', 'BAR', Sex.female, 42)
        p.forname = 'Rosetta'
>       verify(p)
E       approvaltests.approval_exception.ApprovalException: Approval Mismatch, received != approved
E               Approved: /home/cram/Workdir/temporary_projects/approvals/tests/test_person.test_change_name.approved.txt
E               Received: /home/cram/Workdir/temporary_projects/approvals/tests/test_person.test_change_name.received.txt

tests/test_person.py:14: ApprovalException
=========================================================================================================================================================== short test summary info ===========================================================================================================================================================
FAILED tests/test_person.py::test_change_name - approvaltests.approval_exception.ApprovalException: Approval Mismatch, received != approved
========================================================================================================================================================= 1 failed, 1 passed in 0.12s =========================================================================================================================================================

I don't understand why I get such a behavoir.

marcdexet-cnrs commented 2 years ago

As I'm using VSCode and it's testRunner, it's bothering as if a test fails, I only get this output in logs.

./tests/test_person.py::test_change_name Failed: [undefined]RuntimeError: This machine has no reporter configuration
def test_change_name():
        p = Person('Foo', 'BAR', Sex.female, 42)
        p.forname = 'Rosetta'
>       verify(p)

tests/test_person.py:14: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.8/site-packages/approvaltests/file_approver.py:53: in verify
    ok = self.verify_files(approved, received, reporter,comparator)
.venv/lib/python3.8/site-packages/approvaltests/file_approver.py:70: in verify_files
    worked = reporter.report(received_file, approved_file)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <approvaltests.reporters.generic_diff_reporter_factory.NoConfigReporter object at 0x7fa508738fd0>
received_path = '/home/cram/Workdir/temporary_projects/approvals/tests/test_person.test_change_name.received.txt'
approved_path = '/home/cram/Workdir/temporary_projects/approvals/tests/test_person.test_change_name.approved.txt'

    def report(self, received_path: str, approved_path: str) -> bool:
>       raise RuntimeError("This machine has no reporter configuration")
E       RuntimeError: This machine has no reporter configuration

.venv/lib/python3.8/site-packages/approvaltests/reporters/generic_diff_reporter_factory.py:16: RuntimeError

Total number of tests expected to run: 2
Total number of tests run: 2
Total number of tests passed: 1
Total number of tests failed: 1
Total number of tests failed with errors: 0
Total number of tests skipped: 0
Total number of tests with no result data: 0
Finished running tests!

> Test run finished at 04/04/2022, 18:27:16 <