pytest-dev / unittest2pytest

helps rewriting Python `unittest` test-cases into `pytest` test-cases
GNU General Public License v3.0
128 stars 27 forks source link

Output bug reporting howto if result contains syntax-errors #19

Open jayvdb opened 7 years ago

jayvdb commented 7 years ago

To allow the tool to be used even with problems like https://github.com/pytest-dev/unittest2pytest/issues/17 and https://github.com/pytest-dev/unittest2pytest/issues/18 , I think it would be helpful to do a syntax parse on the generated file before writing it, so files which will be broken can be skipped.

htgoebel commented 7 years ago

To be honest: I don't see much use in implementing this. Spotting this kind of issues is very easy, as they pop up as soon as you try to run your test-suite.

A "savemode" might even make errors like #18 pass unseen, since the test-suite might still run with the unchanged code.

RonnyPfannschmidt commented 7 years ago

perhaps a better choice is simply to error out if files failed to get fixed in a parsable manner so people can use the tool and have a working testsuite before and after even if some transformations broke

perhaps allowing a opt-in to write out the unparsable files for manual fixing if intended

htgoebel commented 7 years ago

perhaps a better choice is simply to error out if files failed to get fixed in a parsable manner

ACK. But for this the fixes need to discover that their have some parse-tree they can not convert. And even then: If a huge test-file contains one construct that can not be handled, erroring out would inhibit the other constructs to be not converted – which I don't think is a good idea.

Anyway, IMHO syntax-errors in the converted files are a no-brainer: trivial to spot and trivial to solve. unittest2pytest is not a silver bullet, but a helper – even it it tries to make the job as good as possible. If we error out or warn about these cases, we get less tickets pointing to fields of improvement.

RonnyPfannschmidt commented 7 years ago

the error should return a bug reporting howto ^^

htgoebel commented 7 years ago

Rethinking this topic, I can to the conclusion that even unparsable files should be written.

Let's assume in a huge test-file one test can not be converted correctly (produces a syntax error). Now when writing this file to disk, the programmer needs to fix one problem, while if the file would not be written, the programmer would need to convert the whole file manually.

htgoebel commented 7 years ago

Implementation of the bug reporting howto would be easy:

The how-to could be as short as one for two sentences IMO.

Mattwmaster58 commented 4 years ago

Related to #45