Package: simple_test_generator
simple_test_generatorAutomated, comprehensive and clean pytest test cases.DescriptionIf we format our code with tools like Black, then why don't we do the same with our tests?Helps you reach 100% test coverage with real-world test cases.
Tests that are generated "just work", i.e they are clean, unaware of implementation details, and doesn't require active maintenance.It works well if your functions aredeterministic(e.g pure).If not, then you should probably make them so!It's DDT for pytest (development-driven testing, data-driven tests, or both :nerd_face:)why?Too tedious/hard to generate custom data for your application?save time by having tests generated for you :tada:dramatically increase test code coverage with little effortwrite more maintainable tests by separating code and datahelps you organise your test code consistently in new projects, or:replace your existing disorganised test code :+1:accelerate your migration to pytestTests that you write manually can still be made to follow the same conventions as simple_test_generator for consistencyUsing in normal runsUsing while running teststhen, confirm that your test cases expected value are correct.finally, install it only as a test dependency.DemosSee botostubs going from 0 to 99% under 20 seconds!Releasing on PyPIpipenv shellflit buildflit publishEnter password when prompted.DocsRunning over and over write test cases in new files to avoid overwriting your previous test cases. The filenames are appended with -00, -01, ... for up to 10 files.If your function arguments are not serialisable, then test cases won't be generated. You will see an error in the logs for that function.Dev docssection still rough; personal notescalling-m simple_test_generatorisn't dropping in debugger. It works when using as a librarywith Recorder(): ...NotesIt won't be able to support all types of data, e.g asserting functions that return other functions. See section on how to handle this.This project uses pickling to load the test data. If you're the one generated test data, then it should be fine loading it during tests. Otherwise, don't load untrusted test data.FeaturesHandles functions that return generators by automatically extending these into Python lists so that they can be asserted.TODOMinor issue: functions in your main module may be loaded twice, creating identical test cases twice for that function. (maybe happening only in this project)Support functions that return functions. We need a reliable way to assert equivalence between a function and its deserialised representation.RelatedThese projects resemble this one but mine requires much less effort on your part and generates even less boilerplate :blush:https://smarie.github.io/python-pytest-cases/https://github.com/Figglewatts/pytestgenWhat if you have test failures?It may be due to a bug in simple_test_generator but it's probably because it's difficult to serialise all data types, e.g file descriptors.Cases that you should handle on your own:Assertion does not work properly on your objectsYou should define an__eq__function in your class. This will ensure that pytest asserts the return values properly.How to report in issueRaise an issuehereabout the test failure (or upvote an existing one)Paste your function code (or its signature)Paste the json file that simple_test_generator generated, e.gtest-data/path/to/function/01.jsonState what you were expectingState what happened insteadCopyrightReleased under the MIT licence. See file namedLICENCEfor details.