Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

How can I test Turtle library functions with pytest?

$
0
0

Long story short: I'm a middle school computer science teacher who has recently completely lost a program I used to teach Python syntax. I'm trying to rebuild it myself using pytest. My background isn't in Python, but Java, JavaScript, and C#, but the district I work for is insisting on Python. So I'm teaching myself the syntax as well as teaching my students. (It helps that I have the foundations of code so I can learn faster than them!)

I'm trying to figure out how to test to see if my students have completed the Turtle code correctly.

So if I ask a student to draw a dotted line with Turtle and they instead draw a solid line, how can I test this? Logically, it should be possible to have pytest check code instead of output, right?

The code should be (and yes, this is the precursor to using it in a loop):

def dotted_line():  t.pendown()  t.forward(5)  t.penup()  t.forward(5)  t.pendown()  t.forward(5)

There has to be a way to test this, right? Or can I convert the code to an output in the test?


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>