from turtle import Turtle import random from configurator import get_attributes attributes = get_attributes('config.csv') class Food(Turtle): """Controls everything related to the food. Turtle subclass. Functions: - refresh : creates a new piece of food """ def __init__(self): super().__init__() self.shape(attributes[3]) self.penup() self.shapesize(stretch_len=0.5, stretch_wid=0.5) self.color(attributes[2]) self.speed('fastest') self.refresh() def refresh(self): """Creates a new random set of coordinates. A new piece of food is created at the coordinates randomly generated here. """
def test_empty_datafile(self): """Test for an empty csv file.""" df = get_attributes(self.temporary_file) self.assertFalse(df)
def test_file_is_not_csv(self): """Test for a file with a wrong format.""" df = get_attributes(self.temporary_file) self.assertFalse(df)
def test_no_datafile(self): """Test for a non-existent file.""" df = get_attributes("/tmp/nonexistentfile-wewefwwe") self.assertFalse(df)