Using pytest with repl.it: step-by-step, with animation
functions.py
main.py
, use from functions import my_func
for each functiontests.py
with import pytest
at the topRun
button like usualpytest tests.py
in the Shell
windowImportant to know:
Run
, it may take some time for pytest
to be installedpytest tests.py
too soon, you’ll get an errorConsole
window, for pytest
to be installed)Here’s a repl that you can “fork” to play with this code for yourself:
Here is an example of rewriting the first_factor_found function using a while loop instead of a for loop
@PhillipConrad/spis2022-FOCS-0804
Some notes on while loops:
while condition:
on the first line, where condition
is something that’s true or false.while condition:
do_something()
do_something_else()
A more specific example:
i=1;
while i<10:
print("i=",i)
i+=1
Here’s the output:
i= 1
i= 2
i= 3
i= 4
i= 5
i= 6
i= 7
i= 8
i= 9