Permalink
Please sign in to comment.
Showing
with
635 additions
and 490 deletions.
- +2 −0 src/platform/python/.pylintrc
- +21 −14 src/platform/python/CMakeLists.txt
- +1 −5 src/platform/python/_builder.py
- +5 −4 src/platform/python/cinema/__init__.py
- +14 −20 src/platform/python/cinema/movie.py
- +39 −34 src/platform/python/cinema/test.py
- +2 −2 src/platform/python/cinema/util.py
- +18 −15 src/platform/python/mgba/__init__.py
- +9 −8 src/platform/python/mgba/arm.py
- +114 −91 src/platform/python/mgba/core.py
- +20 −15 src/platform/python/mgba/debugger.py
- +1 −0 src/platform/python/mgba/gamedata.py
- +39 −32 src/platform/python/mgba/gb.py
- +37 −26 src/platform/python/mgba/gba.py
- +39 −33 src/platform/python/mgba/image.py
- +16 −10 src/platform/python/mgba/log.py
- +3 −1 src/platform/python/mgba/lr35902.py
- +35 −35 src/platform/python/mgba/memory.py
- +28 −24 src/platform/python/mgba/png.py
- +10 −6 src/platform/python/mgba/thread.py
- +10 −5 src/platform/python/mgba/tile.py
- +108 −95 src/platform/python/mgba/vfs.py
- +4 −0 src/platform/python/setup.cfg
- +38 −0 src/platform/python/setup.py
- +4 −4 src/platform/python/test_cinema.py
- +17 −10 src/platform/python/tests/mgba/test_vfs.py
- +1 −1 version.cmake
| @@ -0,0 +1,2 @@ | ||
| +[MESSAGES CONTROL] | ||
| +disable=line-too-long,missing-docstring,too-few-public-methods,too-many-instance-attributes,too-many-public-methods,wrong-import-order |
| @@ -1,96 +1,101 @@ | ||
| -import os, os.path | ||
| -import mgba.core, mgba.image | ||
| +import os | ||
| +import os.path | ||
| +import mgba.core | ||
| +import mgba.image | ||
| import cinema.movie | ||
| import itertools | ||
| import glob | ||
| import re | ||
| import yaml | ||
| from copy import deepcopy | ||
| from cinema import VideoFrame | ||
| -from cinema.util import dictMerge | ||
| +from cinema.util import dict_merge | ||
| + | ||
| class CinemaTest(object): | ||
| TEST = 'test.(mvl|gb|gba|nds)' | ||
| def __init__(self, path, root, settings={}): | ||
| - self.fullPath = path or [] | ||
| - self.path = os.path.abspath(os.path.join(root, *self.fullPath)) | ||
| + self.full_path = path or [] | ||
| + self.path = os.path.abspath(os.path.join(root, *self.full_path)) | ||
| self.root = root | ||
| self.name = '.'.join(path) | ||
| self.settings = settings | ||
| try: | ||
| with open(os.path.join(self.path, 'manifest.yml'), 'r') as f: | ||
| - dictMerge(self.settings, yaml.safe_load(f)) | ||
| + dict_merge(self.settings, yaml.safe_load(f)) | ||
| except IOError: | ||
| pass | ||
| self.tests = {} | ||
| def __repr__(self): | ||
| return '<%s %s>' % (self.__class__.__name__, self.name) | ||
| - def setUp(self): | ||
| + def setup(self): | ||
| results = [f for f in glob.glob(os.path.join(self.path, 'test.*')) if re.search(self.TEST, f)] | ||
| - self.core = mgba.core.loadPath(results[0]) | ||
| + self.core = mgba.core.load_path(results[0]) | ||
| if 'config' in self.settings: | ||
| self.config = mgba.core.Config(defaults=self.settings['config']) | ||
| - self.core.loadConfig(self.config) | ||
| + self.core.load_config(self.config) | ||
| self.core.reset() | ||
| - def addTest(self, name, cls=None, settings={}): | ||
| + def add_test(self, name, cls=None, settings={}): | ||
| cls = cls or self.__class__ | ||
| - newSettings = deepcopy(self.settings) | ||
| - dictMerge(newSettings, settings) | ||
| - self.tests[name] = cls(self.fullPath + [name], self.root, newSettings) | ||
| + new_settings = deepcopy(self.settings) | ||
| + dict_merge(new_settings, settings) | ||
| + self.tests[name] = cls(self.full_path + [name], self.root, new_settings) | ||
| return self.tests[name] | ||
| - def outputSettings(self): | ||
| - outputSettings = {} | ||
| + def output_settings(self): | ||
| + output_settings = {} | ||
| if 'frames' in self.settings: | ||
| - outputSettings['limit'] = self.settings['frames'] | ||
| + output_settings['limit'] = self.settings['frames'] | ||
| if 'skip' in self.settings: | ||
| - outputSettings['skip'] = self.settings['skip'] | ||
| - return outputSettings | ||
| + output_settings['skip'] = self.settings['skip'] | ||
| + return output_settings | ||
| def __lt__(self, other): | ||
| return self.path < other.path | ||
| + | ||
| class VideoTest(CinemaTest): | ||
| BASELINE = 'baseline_%04u.png' | ||
| - def setUp(self): | ||
| - super(VideoTest, self).setUp(); | ||
| + def setup(self): | ||
| + super(VideoTest, self).setup() | ||
| self.tracer = cinema.movie.Tracer(self.core) | ||
| - def generateFrames(self): | ||
| - for i, frame in zip(itertools.count(), self.tracer.video(**self.outputSettings())): | ||
| + def generate_frames(self): | ||
| + for i, frame in zip(itertools.count(), self.tracer.video(**self.output_settings())): | ||
| try: | ||
| baseline = VideoFrame.load(os.path.join(self.path, self.BASELINE % i)) | ||
| yield baseline, frame, VideoFrame.diff(baseline, frame) | ||
| except IOError: | ||
| yield None, frame, (None, None) | ||
| def test(self): | ||
| - self.baseline, self.frames, self.diffs = zip(*self.generateFrames()) | ||
| + self.baseline, self.frames, self.diffs = zip(*self.generate_frames()) | ||
| assert not any(any(diffs[0].image.convert("L").point(bool).getdata()) for diffs in self.diffs) | ||
| - def generateBaseline(self): | ||
| - for i, frame in zip(itertools.count(), self.tracer.video(**self.outputSettings())): | ||
| + def generate_baseline(self): | ||
| + for i, frame in zip(itertools.count(), self.tracer.video(**self.output_settings())): | ||
| frame.save(os.path.join(self.path, self.BASELINE % i)) | ||
| -def gatherTests(root=os.getcwd()): | ||
| + | ||
| +def gather_tests(root=os.getcwd()): | ||
| tests = CinemaTest([], root) | ||
| for path, _, files in os.walk(root): | ||
| test = [f for f in files if re.match(CinemaTest.TEST, f)] | ||
| if not test: | ||
| continue | ||
| prefix = os.path.commonprefix([path, root]) | ||
| suffix = path[len(prefix)+1:] | ||
| - testPath = suffix.split(os.sep) | ||
| - testRoot = tests | ||
| - for component in testPath[:-1]: | ||
| - newTest = testRoot.tests.get(component) | ||
| - if not newTest: | ||
| - newTest = testRoot.addTest(component) | ||
| - testRoot = newTest | ||
| - testRoot.addTest(testPath[-1], VideoTest) | ||
| + test_path = suffix.split(os.sep) | ||
| + test_root = tests | ||
| + for component in test_path[:-1]: | ||
| + new_test = test_root.tests.get(component) | ||
| + if not new_test: | ||
| + new_test = test_root.add_test(component) | ||
| + test_root = new_test | ||
| + test_root.add_test(test_path[-1], VideoTest) | ||
| return tests |
Oops, something went wrong.
0 comments on commit
7fa8de1