<commit_before>from __future__ import unicode_literals
import pytest
from queue import Element
from queue import Queue


def test_element_init():
    ''' Test Element init. '''
    m = Element(3)
    assert m.val == 3
    assert m.behind is None


def test_queue_init():
    ''' Test Queue init. '''
    l = Queue()
    assert l.front is None
    assert l.back is None


def test_queue_enqueue():
    ''' Test enqueue method. '''
    l = Queue()

    ''' Test enqueue to empty queue '''
    l.enqueue(10)
    ''' Check front element value and pointers. '''
    assert l.front.ahead is None
    assert l.front.val == 10
    assert l.front.behind is None

    ''' Check back element value and pointers. '''
    assert l.back.ahead is None
    assert l.back.val == 10
    assert l.back.behind is None

    ''' Check that front element is the back element. '''
    assert l.front is l.back

    ''' Test queue of two elements '''
    l.enqueue("String")
    ''' Check front element value and pointers. '''
    assert l.front.ahead is None
    assert l.front.val == 10
    assert l.front.behind.val == "String"

    ''' Check back element value and pointers. '''
    assert l.back.ahead.val == 10
    assert l.back.val == "String"
    assert l.back.behind is None

    ''' Check that front element and back elements point at each other. '''
    assert l.back.ahead == l.front
    assert l.front.behind == l.back

    ''' Test queue of three elements '''
    l.enqueue([])

    ''' Check that front and back elements point too the same element. '''
    assert l.front.behind == l.back.ahead

    ''' Check middle element value and pointers. '''
    assert l.back.ahead.ahead is l.front
    assert l.back.ahead.val == "String"
    assert l.back.ahead.behind is l.back


def test_queue_dequeue():
    ''' Test dequeue method. '''
    l = Queue()

    ''' Test dequeue on empty queue. '''
    with pytest.raises(IndexError):
        l.dequeue()

    ''' Test dequeue on non-empty queue. '''
    l.enqueue(10)
    l.enqueue("String")
    l.enqueue([])

    ''' Check return of dequeue. '''
    assert l.dequeue() == 10

    ''' Check that front of queue has be reassigned. '''
    assert l.front.ahead is None
    assert l.front.val == "String"
    assert l.front.behind.val == []


def test_queue_size():
    ''' Test size method. '''
    l = Queue()

    ''' Test size on empty queue. '''
    assert l.size() == 0

    ''' Test size on non-empty queue. '''
    l.enqueue('Bob')
    l.enqueue(32)
    l.enqueue('Things')
    assert l.size() == 3
<commit_msg>change tested list to be non-empty.<commit_after>from __future__ import unicode_literals
import pytest
from queue import Element
from queue import Queue


def test_element_init():
    ''' Test Element init. '''
    m = Element(3)
    assert m.val == 3
    assert m.behind is None


def test_queue_init():
    ''' Test Queue init. '''
    l = Queue()
    assert l.front is None
    assert l.back is None


def test_queue_enqueue():
    ''' Test enqueue method. '''
    l = Queue()

    ''' Test enqueue to empty queue '''
    l.enqueue(10)
    ''' Check front element value and pointers. '''
    assert l.front.ahead is None
    assert l.front.val == 10
    assert l.front.behind is None

    ''' Check back element value and pointers. '''
    assert l.back.ahead is None
    assert l.back.val == 10
    assert l.back.behind is None

    ''' Check that front element is the back element. '''
    assert l.front is l.back

    ''' Test queue of two elements '''
    l.enqueue("String")
    ''' Check front element value and pointers. '''
    assert l.front.ahead is None
    assert l.front.val == 10
    assert l.front.behind.val == "String"

    ''' Check back element value and pointers. '''
    assert l.back.ahead.val == 10
    assert l.back.val == "String"
    assert l.back.behind is None

    ''' Check that front element and back elements point at each other. '''
    assert l.back.ahead == l.front
    assert l.front.behind == l.back

    ''' Test queue of three elements '''
    l.enqueue([])

    ''' Check that front and back elements point too the same element. '''
    assert l.front.behind == l.back.ahead

    ''' Check middle element value and pointers. '''
    assert l.back.ahead.ahead is l.front
    assert l.back.ahead.val == "String"
    assert l.back.ahead.behind is l.back


def test_queue_dequeue():
    ''' Test dequeue method. '''
    l = Queue()

    ''' Test dequeue on empty queue. '''
    with pytest.raises(IndexError):
        l.dequeue()

    ''' Test dequeue on non-empty queue. '''
    l.enqueue(10)
    l.enqueue("String")
    l.enqueue([1, "string"])

    ''' Check return of dequeue. '''
    assert l.dequeue() == 10

    ''' Check that front of queue has be reassigned. '''
    assert l.front.ahead is None
    assert l.front.val == "String"
    assert l.front.behind.val == [1, "string"]


def test_queue_size():
    ''' Test size method. '''
    l = Queue()

    ''' Test size on empty queue. '''
    assert l.size() == 0

    ''' Test size on non-empty queue. '''
    l.enqueue('Bob')
    l.enqueue(32)
    l.enqueue('Things')
    assert l.size() == 3

{'fraction_non_alphanumeric': 0.1349669389342668, 'fraction_numerical': 0.008168028004667444, 'mean_word_length': 2.5226027397260276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7078526', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1554, 'n_words': 542}