Permalink
Browse files

Switch tox to use unittest instead of pytest (#352)

* Switch tox to use unittest instead of pytest to reduce build dependencies.
* Specify place to find tests.
* flake8 to skip tox and dist directories.
* Lint pass to reflect newer flake8
* Remove explicit include from Makefile, fall back to tox.ini.
* Switch back to new style binary operators.
  • Loading branch information...
ssteinbach committed Oct 24, 2018
1 parent 9459b2c commit 3cb113557bd8704286d1e3e70e8d3d0ca2281bd6
View
@@ -38,7 +38,7 @@ test: test-core test-contrib
test-core: python-version
@echo "$(ccgreen)Running Core tests...$(ccend)"
@python -m unittest discover tests $(TEST_ARGS)
@python -m unittest discover -s tests $(TEST_ARGS)
test-contrib: python-version
@echo "$(ccgreen)Running Contrib tests...$(ccend)"
@@ -66,7 +66,7 @@ coverage-contrib: python-version
# run all the unit tests, stopping at the first failure
test_first_fail: python-version
@python -m unittest discover tests --failfast
@python -m unittest discover -s tests --failfast
# remove pyc files
clean:
@@ -97,7 +97,7 @@ ifndef FLAKE8_PROG
$(ccblue) http://flake8.pycqa.org/en/latest/index.html#installation$(newline)$(ccend)\
$(dev_deps_message))
endif
@python -m flake8 --exclude build
@python -m flake8
# generate documentation in html
@@ -47,7 +47,7 @@ class EDLParseError(otio.exceptions.OTIOError):
# regex for parsing the playback speed of an M2 event
SPEED_EFFECT_RE = re.compile(
"(?P<name>.*?)\s*(?P<speed>[0-9\.]*)\s*(?P<tc>[0-9:]{11})$"
r"(?P<name>.*?)\s*(?P<speed>[0-9\.]*)\s*(?P<tc>[0-9:]{11})$"
)
@@ -58,7 +58,7 @@ class EDLParseError(otio.exceptions.OTIOError):
transition_regex_map = {
'C': 'cut',
'D': 'dissolve',
'W\d{3}': 'wipe',
r'W\d{3}': 'wipe',
'KB': 'key_background',
'K': 'key_foreground',
'KO': 'key_overlay'
@@ -297,7 +297,7 @@ def parse_edl(self, edl_string, rate=24):
comments = []
while edl_lines:
if re.match('^\D', edl_lines[0]):
if re.match(r'^\D', edl_lines[0]):
comments.append(edl_lines.pop(0))
else:
break
@@ -314,7 +314,7 @@ def parse_edl(self, edl_string, rate=24):
# comments are string tags used by the reader to get extra
# information not able to be found in the restricted edl
# format
if re.match('^\D', edl_lines[0]):
if re.match(r'^\D', edl_lines[0]):
comments.append(edl_lines.pop(0))
else:
break
@@ -396,7 +396,11 @@ def make_clip(self, comment_data):
if asc_sop:
triple = r'([-+]?[\d.]+) ([-+]?[\d.]+) ([-+]?[\d.]+)'
m = re.match(
r'\(' + triple + '\)\s*\(' + triple + '\)\s*\(' + triple + '\)',
r'\('
+ triple
+ r'\)\s*\('
+ triple + r'\)\s*\('
+ triple + r'\)',
asc_sop
)
if m:
@@ -539,7 +543,7 @@ def parse(self, line):
class CommentHandler(object):
# this is the for that all comment 'id' tags take
regex_template = '\*?\s*{id}:?\s*(?P<comment_body>.*)'
regex_template = r'\*?\s*{id}:?\s*(?P<comment_body>.*)'
# this should be a map of all known comments that we can read
# 'FROM CLIP' or 'FROM FILE' is a required comment to link media
@@ -59,9 +59,9 @@ def _get_next_item(
track = track_algo.track_trimmed_to_range(track, trim_range)
for item in track:
if (
item.visible() or
track_index == 0 or
isinstance(item, schema.Transition)
item.visible()
or track_index == 0
or isinstance(item, schema.Transition)
):
yield item
else:
@@ -601,22 +601,22 @@ def _fix_transitions(thing):
# Was the item before us a Transition?
if c > 0 and isinstance(
thing[c-1],
thing[c - 1],
otio.schema.Transition
):
pre_trans = thing[c-1]
pre_trans = thing[c - 1]
if child.source_range is None:
child.source_range = child.trimmed_range()
child.source_range.start_time += pre_trans.in_offset
child.source_range.duration -= pre_trans.in_offset
# Is the item after us a Transition?
if c < len(thing)-1 and isinstance(
thing[c+1],
if c < len(thing) - 1 and isinstance(
thing[c + 1],
otio.schema.Transition
):
post_trans = thing[c+1]
post_trans = thing[c + 1]
if child.source_range is None:
child.source_range = child.trimmed_range()
@@ -660,26 +660,26 @@ def _simplify(thing):
del thing[c]
# Look for Stacks within Stacks
c = len(thing)-1
c = len(thing) - 1
while c >= 0:
child = thing[c]
# Is my child a Stack also?
if (
isinstance(child, otio.schema.Stack) and
not _has_effects(child)
isinstance(child, otio.schema.Stack)
and not _has_effects(child)
):
# Pull the child's children into the parent
num = len(child)
thing[c:c+1] = child[:]
thing[c:c + 1] = child[:]
# TODO: We may be discarding metadata, should we merge it?
# TODO: Do we need to offset the markers in time?
thing.markers.extend(child.markers)
# Note: we don't merge effects, because we already made
# sure the child had no effects in the if statement above.
c = c+num
c = c-1
c = c + num
c = c - 1
# skip redundant containers
if _is_redundant_container(thing):
@@ -710,13 +710,13 @@ def _has_effects(thing):
def _is_redundant_container(thing):
return (
isinstance(thing, otio.core.Composition)
and (
isinstance(thing, otio.core.Composition) and
(
# A container with length of one
len(thing) == 1
len(thing) == 1 and
# ...which contains a container
and isinstance(thing[0], otio.core.Composition)
isinstance(thing[0], otio.core.Composition)
)
)
@@ -39,7 +39,7 @@ def _parse_data_line(line, columns, fps):
row.extend([""] * (len(columns) - len(row)))
if len(row) > len(columns):
raise ALEParseError("Too many values on row: "+line)
raise ALEParseError("Too many values on row: " + line)
try:
@@ -84,7 +84,9 @@ def _parse_data_line(line, columns, fps):
if end is None:
end = start + duration
if end != start + duration:
raise ALEParseError("Inconsistent Start, End, Duration: "+line)
raise ALEParseError(
"Inconsistent Start, End, Duration: " + line
)
clip.source_range = otio.opentime.TimeRange(
start,
duration
@@ -132,21 +134,21 @@ def nextline(lines):
break
if "\t" not in line:
raise ALEParseError("Invalid Heading line: "+line)
raise ALEParseError("Invalid Heading line: " + line)
segments = line.split("\t")
while len(segments) >= 2:
key, val = segments.pop(0), segments.pop(0)
header[key] = val
if len(segments) != 0:
raise ALEParseError("Invalid Heading line: "+line)
raise ALEParseError("Invalid Heading line: " + line)
if "FPS" in header:
fps = float(header["FPS"])
if line.strip() == "Column":
if len(lines) == 0:
raise ALEParseError("Unexpected end of file after: "+line)
raise ALEParseError("Unexpected end of file after: " + line)
line = nextline(lines)
columns = line.split("\t")
@@ -250,8 +250,8 @@ def main():
otio.adapters.write_to_string(
read_sequence(),
"otio_json"
)
+ "\nOTIO_JSON_END\n"
) +
"\nOTIO_JSON_END\n"
)
cmds.quit(force=True)
@@ -324,7 +324,7 @@ def _add_burnin(self, text, align, options, draw):
data.update(options)
data.update(_drawtext(align, resolution, text, options))
if 'font' in data and _is_windows():
data['font'] = data['font'].replace(os.sep, r'\\'+os.sep)
data['font'] = data['font'].replace(os.sep, r'\\' + os.sep)
data['font'] = data['font'].replace(':', r'\:')
self.filters['drawtext'].append(draw % data)
@@ -418,7 +418,7 @@ def _drawtext(align, resolution, text, options):
def _frames_to_timecode(frames, framerate):
return '{0:02d}:{1:02d}:{2:02d}:{3:02d}'.format(
int(frames / (3600*framerate)),
int(frames / (60*framerate) % 60),
int(frames / (3600 * framerate)),
int(frames / (60 * framerate) % 60),
int(frames / framerate % 60),
int(frames % framerate))
@@ -1373,8 +1373,8 @@ def _setup_track_info(self, media_track):
# If we found a track start or one isn't already set in the
# metadata, create the tag for it.
if (
track_start is not None
or 'EXT-X-MEDIA-SEQUENCE' not in self._playlist_tags
track_start is not None or
'EXT-X-MEDIA-SEQUENCE' not in self._playlist_tags
):
# Choose a reasonable track start default
if track_start is None:
@@ -120,7 +120,7 @@ def read_from_file(filepath):
start = out.find(sentinel_str)
end = out.find(end_sentinel_str)
result = adapters.read_from_string(
out[start+len(sentinel_str):end],
out[start + len(sentinel_str):end],
"otio_json"
)
Oops, something went wrong.

0 comments on commit 3cb1135

Please sign in to comment.