Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import shutil
import tempfile
import unittest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR is aiming to switch from unittest to pytest, I'd look at the uses of unittest within this module and see if you can replace them with pytest equivalents.

One example I see is the usage of the @unittest.skipUnless decorator - this can be replaced by "inverting" the logic on the test case and using @pytest.mark.skipif instead.

import pytest

import opentimelineio as otio


class TestCoreFunctions(unittest.TestCase):
Comment thread
1rvine marked this conversation as resolved.
Outdated
def setUp(self):
self.tmpDir = tempfile.mkdtemp()

def tearDown(self):
shutil.rmtree(self.tmpDir)


@pytest.fixture()
def dir():
return tempfile.mkdtemp()
Comment thread
1rvine marked this conversation as resolved.
Outdated

def test_deserialize_json_from_file_errors(self):
"""Verify that the bindings return the correct errors based on the errno"""
if sys.version_info[0] < 3:
Expand All @@ -25,7 +25,8 @@ def test_deserialize_json_from_file_errors(self):

with self.assertRaises(excType) as exc:
otio.core.deserialize_json_from_file('non-existent-file-here')
self.assertIsInstance(exc.exception, excType)
assert (exc.exception, excType)
Comment thread
1rvine marked this conversation as resolved.
Outdated


@unittest.skipUnless(not sys.platform.startswith("win"), "requires non Windows sytem") # noqa
def test_serialize_json_to_file_errors_non_windows(self):
Expand All @@ -36,8 +37,9 @@ def test_serialize_json_to_file_errors_non_windows(self):
excType = IsADirectoryError # noqa: F821

with self.assertRaises(excType) as exc:
otio.core.serialize_json_to_file({}, self.tmpDir)
self.assertIsInstance(exc.exception, excType)
otio.core.serialize_json_to_file({}, tempfile.mkdtemp())
assert (exc.exception, excType)
Comment thread
1rvine marked this conversation as resolved.
Outdated


@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_serialize_json_to_file_errors_windows(self):
Expand All @@ -48,5 +50,7 @@ def test_serialize_json_to_file_errors_windows(self):
excType = PermissionError # noqa: F821

with self.assertRaises(excType) as exc:
otio.core.serialize_json_to_file({}, self.tmpDir)
self.assertIsInstance(exc.exception, excType)
otio.core.serialize_json_to_file({}, dir())
assert (exc.exception, excType)
Comment thread
1rvine marked this conversation as resolved.
Outdated
def myTestCoreFunctions():
return
Loading