<commit_before>#
# @file main.py
#
# @section License
# Copyright (C) 2016, <NAME>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# This file is part of the Pumbaa project.
#

import harness
from pumbaa import Timer, Event
from harness import assert_raises


def test_help():
    EVENT = Event()
    TIMER = Timer(1, EVENT, 0x1)
    help(Timer)
    help(TIMER)


def test_single_shot_timer():
    EVENT = Event()
    TIMER = Timer((0, 1000000), EVENT, 0x1)
    print("starting single shot timer")
    TIMER.start()
    EVENT.read(0x1)
    print("timeout")


def test_periodic_timer():
    EVENT = Event()
    TIMER = Timer(0.2, EVENT, 0x1, flags=Timer.PERIODIC)
    print("starting periodic timer")
    TIMER.start()
    for i in range(3):
        EVENT.read(0x1)
        print("timeout", i)
    TIMER.stop()


def test_bad_arguments():
    # Wrong type of second argument.
    with assert_raises(TypeError, "expected <class 'Event'>"):
        Timer(1, None, 1)

    # Too few arguments.
    with assert_raises(TypeError, "'mask' argument required"):
        Timer(1, None)


def main():
    testcases = [
        (test_help, "test_help"),
        (test_single_shot_timer, "test_single_shot_timer"),
        (test_periodic_timer, "test_periodic_timer"),
        (test_bad_arguments, "test_bad_arguments")
    ]
    harness.run(testcases)


if __name__ == '__main__':
    main()<commit_msg>Update main.py<commit_after>#
# @file main.py
#
# @section License
# Copyright (C) 2016, <NAME>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# This file is part of the Pumbaa project.
#

import harness
from pumbaa import Timer, Event
from harness import assert_raises


def test_help():
    EVENT = Event()
    TIMER = Timer(1, EVENT, 0x1)
    help(Timer)
    help(TIMER)


def test_single_shot_timer():
    EVENT = Event()
    TIMER = Timer((0, 1000000), EVENT, 0x1)
    print("starting single shot timer")
    TIMER.start()
    EVENT.read(0x1)
    print("timeout")


def test_periodic_timer():
    EVENT = Event()
    TIMER = Timer(0.2, EVENT, 0x1, flags=Timer.PERIODIC)
    print("starting periodic timer")
    TIMER.start()
    for i in range(3):
        EVENT.read(0x1)
        print("timeout", i)
    TIMER.stop()


def test_bad_arguments():
    EVENT = Event()

    # Wrong type of second argument.
    with assert_raises(TypeError, "expected <class 'Event'>"):
        Timer(1, None, 1)

    # Too few arguments.
    with assert_raises(TypeError, "'mask' argument required"):
        Timer(1, None)

    # Too long tuple.
    with assert_raises(ValueError, "expected tuple of length 2"):
        Timer((1, 0, 0), EVENT, 1)


def main():
    testcases = [
        (test_help, "test_help"),
        (test_single_shot_timer, "test_single_shot_timer"),
        (test_periodic_timer, "test_periodic_timer"),
        (test_bad_arguments, "test_bad_arguments")
    ]
    harness.run(testcases)


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.10529045643153527, 'fraction_numerical': 0.01737551867219917, 'mean_word_length': 3.3879408418657566, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4194166', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1189, 'n_words': 411}