I'm working on a simple XML parsing library in Python that uses ctypes to interface with a shared library written in C. This project is mainly a learning experience for another project I'm developing, which converts Markdown to HTML and relies on XML for config and data serialization. I've hit a design decision and would love your insights.
Should I prioritize extensive testing of the input XML files before parsing them, or would it be better to perform basic checks and handle errors as they occur during parsing? Currently, I'm testing thoroughly by checking if the file is null, empty, readable, a valid XML, etc. However, I'm considering if a more efficient approach would be to let the XML pass through my functions and handle any syntax errors when they arise. Looking forward to your thoughts!
1 Answer
I think you should stick to basic sanity checks and then let the rest flow. Extensive input testing can lead to unnecessary complexity, especially for cases that you'll inevitably handle later on. Better to catch exceptions dynamically as they happen. What do you think?

Thanks for your input! Just to clarify, would you care if a library handles errors this way, or does it not matter much?