A Queue is an ordered collection of items of data.

Enqueue adds an item to the collection.

Dequeue removes the item which was added first.

It is a FIFO (first in, first out) structure.

class Queue(object):
    Implementation of a queue in Python
    A FIFO (first in, first out data structure)

    Example usage:

    >>> queue = Queue()
    >>> queue.enqueue(1)
    >>> queue.enqueue(2)
    >>> print(queue.dequeue())


    def __init__(self):
        self.queue_store = []

    def enqueue(self, new_item):
        """ Add a new item to the back of the queue """

    def dequeue(self):
        """ Remove an item from the front of the queue """
        return self.queue_store.pop(0)


import unittest
from queue import Queue

class TestQueue(unittest.TestCase):
    Tests for queue.py

    def setUp(self):
        self.queue = Queue()

    def test_queue_with_one_item(self):
        out = self.queue.dequeue()
        self.assertTrue(out == 1)

    def test_queue_with_multiple_items(self):
        test_list = [1, 2, 3, 4, 5]
        for item in test_list:
        for item in test_list:
            self.assertTrue(self.queue.dequeue() == item)

    def test_queue_with_empty_queue(self):
        """ Check that an IndexError is raised by trying to remove an item from an empty queue """
        self.assertRaises(IndexError, lambda: self.queue.dequeue())

suite = unittest.TestLoader().loadTestsFromTestCase(TestQueue)