Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
⚡ Add support for copying of DayuTimeCode objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Eiken committed Jun 15, 2020
1 parent 1c58a17 commit cea6c3e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ python:
install:
- pip install -r requirements.txt
script:
- export PYTHONPATH=$PYTHONPATH:$(pwd)
- pytest
5 changes: 5 additions & 0 deletions dayu_timecode/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ def __int__(self):
def __neg__(self):
self.time = -self.time
return self

def __copy__(self):
dayu_tc = type(self)(self.frame(), fps=self.fps)
dayu_tc.__dict__.update(self.__dict__)
return dayu_tc

def retime(self, point, retime):
'''
Expand Down
Empty file removed tests/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions tests/test_dayuTimeCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__author__ = 'andyguo'

from unittest import TestCase
import copy
from dayu_timecode.base import DayuTimeCode, Fraction
from dayu_timecode.error import *
from dayu_timecode.config import *
Expand Down Expand Up @@ -308,3 +309,13 @@ def test_retime(self):
self.assertEqual(DayuTimeCode(1440).retime(0, 2.0), 720)
self.assertEqual(DayuTimeCode(1440).retime(-100, 0.5), 2980)
self.assertEqual(DayuTimeCode(1440).retime(2880, 2), 2160)

def test___copy__(self):
a = DayuTimeCode(1440, fps=25)
b = a
a.fps = 50
self.assertEqual(b.fps, 50)
c = copy.copy(a)
c.fps = 25
self.assertNotEqual(c.fps, a.fps)
self.assertNotEqual(c.fps, b.fps)

0 comments on commit cea6c3e

Please sign in to comment.