Exemplo n.º 1
0
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.
        """
Exemplo n.º 2
0
 def test_empty_datafile(self):
     """Test for an empty csv file."""
     df = get_attributes(self.temporary_file)
     self.assertFalse(df)
Exemplo n.º 3
0
 def test_file_is_not_csv(self):
     """Test for a file with a wrong format."""
     df = get_attributes(self.temporary_file)
     self.assertFalse(df)
Exemplo n.º 4
0
 def test_no_datafile(self):
     """Test for a non-existent file."""
     df = get_attributes("/tmp/nonexistentfile-wewefwwe")
     self.assertFalse(df)