<commit_before># -*- coding: utf8 -*-

import unittest

from ffmpegwrapper import FFmpeg, Input, Output, \
    VideoCodec, AudioCodec, VideoFilter
from ffmpegwrapper.options import Option


class FFmpegTestCase(unittest.TestCase):

    def test_input_interface(self):
        input = Input('/old')
        self.assertEqual(list(input), ['-i', '/old'])
        self.assertEqual(input.file, '/old')

        option = Option({'-vf': 'x11grab'})
        input.append(option)
        self.assertEqual(list(input), ['-vf', 'x11grab', '-i', '/old'])
        self.assertEqual(input.pop(), option)

        input.add_option('-vf', 'x11grab')
        self.assertEqual(input.option_containers, [option])

    def test_output_interface(self):
        output = Output('/new')
        self.assertEqual(list(output), ['/new'])
        self.assertEqual(output.file, '/new')

        option = Option({'-vcodec': 'libx264'})
        output.append(option)
        self.assertEqual(list(output), ['-vcodec', 'libx264', '/new'])
        self.assertEqual(output.pop(), option)

        output.add_option('-vcodec', 'libx264')
        self.assertEqual(output.option_containers, [option])

    def test_codec_interface(self):
        codec = VideoCodec('libx264')
        self.assertEqual(list(codec), ['-vcodec', 'libx264'])

        codec = AudioCodec('ac3')
        self.assertEqual(list(codec), ['-acodec', 'ac3'])

    def test_filter_interface(self):
        filter = VideoFilter()
        filter.blackframe(1, 2).crop(792)
        self.assertEqual(list(filter), ['-vf', 'blackframe=1:2,crop=792'])

        output = Output('/new', filter)
        self.assertEqual(
            list(output), ['-vf', 'blackframe=1:2,crop=792', '/new'])

    def test_ffmpeg_interface(self):
        input = Input('/old')
        output = Output('/new')

        ffmpeg = FFmpeg('ffmpeg', input, output)
        self.assertEqual(list(ffmpeg), ['-i', '/old', '/new'])


class VideoFilterTestCase(unittest.TestCase):

    def setUp(self):
        self.filter = VideoFilter()

    def prefix(self, *args):
        return ['-vf'] + list(args)

    def test_blackframe(self):
        self.filter.blackframe(10, 100)
        self.assertEqual(list(self.filter),
            self.prefix('blackframe=10:100'))

    def test_copy(self):
        self.filter.copy()
        self.assertEqual(list(self.filter),
            self.prefix('copy'))
<commit_msg>fix ffmpeg interface test<commit_after># -*- coding: utf8 -*-

import unittest

from ffmpegwrapper import FFmpeg, Input, Output, \
    VideoCodec, AudioCodec, VideoFilter
from ffmpegwrapper.options import Option


class FFmpegTestCase(unittest.TestCase):

    def test_input_interface(self):
        input = Input('/old')
        self.assertEqual(list(input), ['-i', '/old'])
        self.assertEqual(input.file, '/old')

        option = Option({'-vf': 'x11grab'})
        input.append(option)
        self.assertEqual(list(input), ['-vf', 'x11grab', '-i', '/old'])
        self.assertEqual(input.pop(), option)

        input.add_option('-vf', 'x11grab')
        self.assertEqual(input.option_containers, [option])

    def test_output_interface(self):
        output = Output('/new')
        self.assertEqual(list(output), ['/new'])
        self.assertEqual(output.file, '/new')

        option = Option({'-vcodec': 'libx264'})
        output.append(option)
        self.assertEqual(list(output), ['-vcodec', 'libx264', '/new'])
        self.assertEqual(output.pop(), option)

        output.add_option('-vcodec', 'libx264')
        self.assertEqual(output.option_containers, [option])

    def test_codec_interface(self):
        codec = VideoCodec('libx264')
        self.assertEqual(list(codec), ['-vcodec', 'libx264'])

        codec = AudioCodec('ac3')
        self.assertEqual(list(codec), ['-acodec', 'ac3'])

    def test_filter_interface(self):
        filter = VideoFilter()
        filter.blackframe(1, 2).crop(792)
        self.assertEqual(list(filter), ['-vf', 'blackframe=1:2,crop=792'])

        output = Output('/new', filter)
        self.assertEqual(
            list(output), ['-vf', 'blackframe=1:2,crop=792', '/new'])

    def test_ffmpeg_interface(self):
        input = Input('/old')
        output = Output('/new')

        ffmpeg = FFmpeg('ffmpeg', input, output)
        self.assertEqual(list(ffmpeg), ['ffmpeg', '-i', '/old', '/new'])


class VideoFilterTestCase(unittest.TestCase):

    def setUp(self):
        self.filter = VideoFilter()

    def prefix(self, *args):
        return ['-vf'] + list(args)

    def test_blackframe(self):
        self.filter.blackframe(10, 100)
        self.assertEqual(list(self.filter),
            self.prefix('blackframe=10:100'))

    def test_copy(self):
        self.filter.copy()
        self.assertEqual(list(self.filter),
            self.prefix('copy'))

{'fraction_non_alphanumeric': 0.1672870140612076, 'fraction_numerical': 0.020264681555004136, 'mean_word_length': 2.910266774454325, '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': '6823643', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1483, 'n_words': 268}