<commit_before>#!/usr/bin/env python
# vim: set fileencoding=utf8

import textwrap
import tinysrt
import datetime
from nose.tools import eq_ as eq


def test_parse_time():
    eq(
        datetime.timedelta(hours=1, minutes=2, seconds=3, milliseconds=400),
        tinysrt.parse_time('01:02:03,400'),
    )

def test_parse_general():
    srt_data = textwrap.dedent(
        '''\
        7
        00:01:51,980 --> 00:01:55,910
        我快要渴死了 快点倒酒!

        '''
    )
    subs = list(tinysrt.parse(srt_data))

    eq(1, len(subs))

    sub = subs[0]

    eq(7, sub.index)
    eq(
        datetime.timedelta(
            hours=0,
            minutes=1,
            seconds=51,
            milliseconds=980,
        ),
        sub.start,
    )
    eq(
        datetime.timedelta(
            hours=0,
            minutes=1,
            seconds=55,
            milliseconds=910,
        ),
        sub.end,
    )
    eq(
        '我快要渴死了 快点倒酒!',
        sub.content,
    )<commit_msg>Test multiple subs in generic parse() test<commit_after>#!/usr/bin/env python
# vim: set fileencoding=utf8

import textwrap
import tinysrt
import datetime
from nose.tools import eq_ as eq


def test_parse_time():
    eq(
        datetime.timedelta(hours=1, minutes=2, seconds=3, milliseconds=400),
        tinysrt.parse_time('01:02:03,400'),
    )

def test_parse_general():
    srt_data = textwrap.dedent(
        '''\
        7
        00:01:51,980 --> 00:01:55,910
        我快要渴死了 快点倒酒!

        8
        00:01:56,480 --> 00:01:58,460
        - 给你  - 谢了
        '''
    )
    subs = list(tinysrt.parse(srt_data))

    eq(2, len(subs))

    eq(7, subs[0].index)
    eq(
        datetime.timedelta(
            hours=0,
            minutes=1,
            seconds=51,
            milliseconds=980,
        ),
        subs[0].start,
    )
    eq(
        datetime.timedelta(
            hours=0,
            minutes=1,
            seconds=55,
            milliseconds=910,
        ),
        subs[0].end,
    )
    eq(
        '我快要渴死了 快点倒酒!',
        subs[0].content,
    )

    eq(8, subs[1].index)
    eq(
        datetime.timedelta(
            hours=0,
            minutes=1,
            seconds=56,
            milliseconds=480,
        ),
        subs[1].start,
    )
    eq(
        datetime.timedelta(
            hours=0,
            minutes=1,
            seconds=58,
            milliseconds=460,
        ),
        subs[1].end,
    )
    eq(
        '- 给你  - 谢了',
        subs[1].content,
    )
{'fraction_non_alphanumeric': 0.12439613526570048, 'fraction_numerical': 0.05837359098228664, 'mean_word_length': 1.4825174825174825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4893550', 'n_tokens_mistral': 965, 'n_tokens_neox': 908, 'n_words': 149}