Testing and Debugging Flashcards

1
Q

Bugs

A

Error/flaw that leads to malfunction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Syntax error

A

incompatibility with syntax of programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Run time error

A

python understands what you are saying but runs into trouble when following your instructions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

logic error

A

design error, code runs but doesn’t do what it’s supposed to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Debugging

A

process of systematically finding and fixing bugs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

PEP8

A

no more than 79 characters per line

4 spaces per indent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Call stack

A
  • one function being called on top of another
  • facilitate function nesting, allow functions to communicate with each other, preserve function’s local state/namespace
  • push and pop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Defensive programming

A
  1. build code bit by bit
  2. testing as you go again known input/output
  3. log each step of process
  4. use comments
  5. lookout for common gotchas
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

General approach to debugging

A
  1. reproduce bug
  2. determine exact problem
  3. eliminate obvious causes
  4. divide process, separate working and non-working parts
  5. reassess info, step through process again
  6. as you proceed, make predictions about what should happen and verify outcome
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Verbosity

A

if verbosity statement in front of each print statement depending on each verbosity, different print statements will be executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

logging library

A

debug

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Inspecting run state with codde

A
  • suspend execution of code and examine variable values with code
  • import code
  • code.interact()
  • interrupts code and throws it out into interpreter, stepping through code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Starred arguments

A
  • = unpacked into individual arguments

* * = unpacked into individual keyword arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Map function

A

applies function to all items in input list

map(function, input list)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Common run-time exceptions

A
  1. Assertion error = assertion fails
  2. index error = index out of range
  3. key error = key not found in dict
    Handle exceptions with try…except…
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Stacking

A
  • stack trace for run time errors, valuable info on cause of bug
  • sequence in which functions are called and how they were called
  • traceback