0

How can I check if a part of my code functions as it should without having to run my program from start every time, which takes 10+ seconds(gathering data from the web) before it gets to the part I'm testing?

Also debugging with print statements seem kind of tricky, because I can't see if the program is behaving as expected so I can only do print statement for what I think the problem is.

The solution to this would be to use a debugger, but I rarely hear anybody talk about it, it seems so weird because the debugger shows what the program is doing instead of you having assumptions of what it is doing.

Why do I never hear about this and how are you supposed to do this?

I've only used PyCharms debugger but prefer programming in online clients which don't have easy to use debuggers.

Martei
  • 5
  • 6
  • _"it seems so weird because the debugger shows what the program is doing instead of you having assumptions of what it is doing."_ And is that a bad thing? _"how are you supposed to do this?"_ By setting a breakpoint and stopping the execution at the point where you think the problem is. _"How can I check if a part of my code functions as it should"_ - unit tests. Anyway, as it is now, this question is too broad and so I am voting to close it. Please see [what is on topic](http://stackoverflow.com/help/on-topic) for further rerefence. – Teemu Risikko Dec 11 '16 at 18:20
  • Resource -> https://www.jetbrains.com/help/pycharm/2016.1/debugging.html – Emmanuel Mtali Dec 11 '16 at 18:23
  • What are those _online clients_, and why do you _prefer programming in_ them despite they _don't have easy to use debuggers_? – Armali Aug 21 '18 at 10:43

1 Answers1

0

You need to lear to write unit tests. Read this question to start.

Read up on Python's out-of-box unittest module.

Community
  • 1
  • 1
Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91