samedi 16 janvier 2021

I want to develop Pytests for my code: is this a good roadmap plan for how to do it?

I want to write pytests for a number of sequential scripts. They all start off one large file which is taken from an outside source. The actual file changes of course but it's always one file nonetheless. My code then creates a large number of different files off of that which is what I want to test.

So my idea was to have a test data folder. It would just have the initial file.

In my Pytest setup method, I would ensure the test data folder and the initial file are there and are the only files present before beginning.

After that, I would test each of my sequential scripts starting off of that file, generating the actual files off of it and saving it in the test data folder, and at the end of each test, I would run an assert to see that the given file that was created holds values that I would expect.

In my Pytest teardown method, I would delete all of the files except the initial file, giving me a clean slate for when I run it next time.

Does this make sense as a way to do things? Is this violating any good-practice rules when it comes to testing?

Aucun commentaire:

Enregistrer un commentaire