From f2d288bb1e7eca9f9c99c08651889163214f5228 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 1 Nov 2018 14:23:15 +0000 Subject: [PATCH] tests: ensure minify() result can be compiled for all of core. --- mitogen/kubectl.py | 1 - mitogen/parent.py | 1 + mitogen/service.py | 2 ++ ...minimize_source_test.py => minify_test.py} | 22 ++++++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) rename tests/{minimize_source_test.py => minify_test.py} (73%) diff --git a/mitogen/kubectl.py b/mitogen/kubectl.py index c2be24c1..681da3b1 100644 --- a/mitogen/kubectl.py +++ b/mitogen/kubectl.py @@ -1,4 +1,3 @@ -# coding: utf-8 # Copyright 2018, Yannig Perré # # Redistribution and use in source and binary forms, with or without diff --git a/mitogen/parent.py b/mitogen/parent.py index 2f9b2079..a11b362e 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -618,6 +618,7 @@ class EofError(mitogen.core.StreamError): the child process. """ # inherits from StreamError to maintain compatibility. + pass class Argv(object): diff --git a/mitogen/service.py b/mitogen/service.py index ffb7308e..dc90b67f 100644 --- a/mitogen/service.py +++ b/mitogen/service.py @@ -395,11 +395,13 @@ class Service(object): Called when a message arrives on any of :attr:`select`'s registered receivers. """ + pass def on_shutdown(self): """ Called by Pool.shutdown() once the last worker thread has exitted. """ + pass class Pool(object): diff --git a/tests/minimize_source_test.py b/tests/minify_test.py similarity index 73% rename from tests/minimize_source_test.py rename to tests/minify_test.py index b98cdebd..2bb335da 100644 --- a/tests/minimize_source_test.py +++ b/tests/minify_test.py @@ -1,3 +1,5 @@ +import glob + import unittest2 import mitogen.minify @@ -12,7 +14,7 @@ def read_sample(fname): return sample -class MinimizeSource(unittest2.TestCase): +class MinimizeSourceTest(unittest2.TestCase): func = staticmethod(mitogen.minify.minimize_source) def test_class(self): @@ -51,5 +53,23 @@ class MinimizeSource(unittest2.TestCase): self.assertEqual(expected, self.func(original)) +class MitogenCoreTest(unittest2.TestCase): + # Verify minimize_source() succeeds for all built-in modules. + func = staticmethod(mitogen.minify.minimize_source) + + def read_source(self, name): + fp = open(name) + try: + return fp.read() + finally: + fp.close() + + def test_minify_all(self): + for name in glob.glob('mitogen/*.py'): + original = self.read_source(name) + minified = self.func(original) + compile(minified, name, 'exec') + + if __name__ == '__main__': unittest2.main()