File: test_examples.py

package info (click to toggle)
opentimelineio 0.18.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 23,480 kB
  • sloc: cpp: 163,182; python: 50,821; ansic: 6,470; makefile: 1,091; sh: 892; xml: 182; javascript: 2
file content (48 lines) | stat: -rw-r--r-- 1,505 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# SPDX-License-Identifier: Apache-2.0
# Copyright Contributors to the OpenTimelineIO project

"""Unit tests for the 'examples'"""
import unittest
import sys
import os
import subprocess


import tempfile

import opentimelineio as otio


class BuildSimpleTimelineExampleTest(unittest.TestCase):
    """use the build_simple_timeline.py example to generate timelines"""

    def test_duration(self):
        with tempfile.TemporaryDirectory() as temp_dir:
            temp_file = os.path.join(temp_dir, "test_basic.otio")

            examples_path = os.path.join(
                os.path.dirname(os.path.dirname(__file__)),
                "examples",
                "build_simple_timeline.py",
            )

            subprocess.check_call(
                [sys.executable, examples_path, temp_file],
                stdout=subprocess.PIPE
            )
            known = otio.adapters.read_from_file(temp_file)

            # TODO: add checks against a couple of the adapters.
            #  This used to include .edl and .xml
            for suffix in [".otio"]:
                this_test_file = temp_file.replace(".otio", suffix)
                subprocess.check_call(
                    [sys.executable, examples_path, this_test_file],
                    stdout=subprocess.PIPE
                )
                test_result = otio.adapters.read_from_file(this_test_file)
                self.assertEqual(known.duration(), test_result.duration())


if __name__ == '__main__':
    unittest.main()