conference logo

Playlist "Swiss Python Summit 2022"

CLI applications & TDD: Never write scripts again

Peter Bittner

As a DevOps engineer, when you write Python code, do you also write tests? If you're like the majority of the folks out there, chances are you don't. Why would you? It's usually just a script, even if it gets longer over time and starts feeling like Bash. – Deep inside you know that writing tests would be needed. It's the prerequisite for test automation, the foundation of release automation. But heck, who cares? It would be cumbersome to do. You write scripts for your automation tasks – Python makes it easy to get started – and you have noticed that they get hard to maintain when they grow and accumulate logic? Sometimes you split up a large script into several files, but that feels like spaghetti code? Several plates of spaghetti. This talk explains why it makes sense to stop hacking glue code and start developing serious CLI applications, test-driven, with automated tests. Even if you have some experience with writing tests, it's not immediately obvious how to get started. You'll get to know the cli-test-helpers package and see a hands-on demonstration of developing a CLI application from scratch, TDD-style. We'll scratch the surface of some popular CLI frameworks (argparse, click, docopt), and you'll take home working code samples that will help you refuse the temptation of writing code without tests, in future. This talk will make you a TDD addict. Come get the drug!

As a DevOps engineer, when you write Python code, do you also write tests? If you're like the majority of the folks out there, chances are you don't. Why would you? It's usually just a script, even if it gets longer over time and starts feeling like Bash. – Deep inside you know that writing tests would be needed. It's the prerequisite for test automation, the foundation of release automation. But heck, who cares? It would be cumbersome to do. You write scripts for your automation tasks – Python makes it easy to get started – and you have noticed that they get hard to maintain when they grow and accumulate logic? Sometimes you split up a large script into several files, but that feels like spaghetti code? Several plates of spaghetti. This talk explains why it makes sense to stop hacking glue code and start developing serious CLI applications, test-driven, with automated tests. Even if you have some experience with writing tests, it's not immediately obvious how to get started. You'll get to know the cli-test-helpers package and see a hands-on demonstration of developing a CLI application from scratch, TDD-style. We'll scratch the surface of some popular CLI frameworks (argparse, click, docopt), and you'll take home working code samples that will help you refuse the temptation of writing code without tests, in future. This talk will make you a TDD addict. Come get the drug!