Bump version to 0.9.6, clean up Python 3 failures
diff --git a/run b/run index 7f18fa9..4c0e809 100755 --- a/run +++ b/run
@@ -87,15 +87,15 @@ def run_tests(args): python = sys.executable - print('Testing running the typ module directly if it is in sys.path.') + # Test running the typ module directly if it is in sys.path. call([python, '-m', 'typ', 'typ.tests.main_test.TestMain.test_basic']) - print('Testing running the runner directly if nothing is in sys.path.') + # Testing running the runner directly if nothing is in sys.path.' home_dir = os.environ['HOME'] call([python, path_to_runner, 'typ.tests.main_test.TestMain.test_basic'], cwd=home_dir) - print('Running the unit tests.') + # Run the remaining tests. call([python, path_to_runner])
diff --git a/typ/runner.py b/typ/runner.py index c2975f1..7f5aeed 100644 --- a/typ/runner.py +++ b/typ/runner.py
@@ -407,6 +407,11 @@ add_tests(suite) else: add_tests(loader.loadTestsFromName(name)) + if hasattr(loader, 'errors') and loader.errors: + # In Python3's version of unittest, loader failures get converted + # into failed test cases, rather than raising exceptions. However, + # the errors also get recorded so you can err out immediately. + raise ImportError(loader.errors) def _run_tests(self, result_set, test_set): h = self.host
diff --git a/typ/tests/main_test.py b/typ/tests/main_test.py index b580973..fe2968a 100644 --- a/typ/tests/main_test.py +++ b/typ/tests/main_test.py
@@ -141,16 +141,17 @@ LOAD_TEST_PY = """ import unittest + +class BaseTest(unittest.TestCase): + pass + +def method_fail(self): + self.fail() + +def method_pass(self): + pass + def load_tests(_, _2, _3): - class BaseTest(unittest.TestCase): - pass - - def method_fail(self): - self.fail() - - def method_pass(self): - pass - setattr(BaseTest, "test_fail", method_fail) setattr(BaseTest, "test_pass", method_pass) suite = unittest.TestSuite() @@ -341,8 +342,7 @@ pass """)} self.check(['-l', 'foo.py'], files=files, ret=1, err='', - rout=('Failed to load "foo.py": No module named ' - '\'?package_that_does_not_exist\'?\n')) + rout=('Failed to load "foo.py":')) def test_import_failure_no_tests(self): files = {'foo.py': 'import unittest'} @@ -359,9 +359,7 @@ """)} _, out, _, _ = self.check([], files=files, ret=1, err='') self.assertIn('Failed to import test module: syn_test', out) - self.assertIn((' syntax error\n' - ' ^\n' - 'SyntaxError: invalid syntax\n'), out) + self.assertIn('SyntaxError: invalid syntax', out) def test_interrupt(self): files = {'interrupt_test.py': d("""\ @@ -385,8 +383,8 @@ def load_tests(_, _2, _3): raise ValueError('this should fail') """)} - self.check([], files=files, ret=1, err='', - out=('foo_test.load_tests() failed: this should fail\n')) + _, out, _, _ = self.check([], files=files, ret=1, err='') + self.assertIn('this should fail', out) def test_load_tests_single_worker(self): files = LOAD_TEST_FILES
diff --git a/typ/tests/pool_test.py b/typ/tests/pool_test.py index e4b8bd7..319c396 100644 --- a/typ/tests/pool_test.py +++ b/typ/tests/pool_test.py
@@ -157,11 +157,11 @@ host = Host() jobs = 2 - self.assertRaises(ValueError, make_pool, + self.assertRaises(Exception, make_pool, host, jobs, _stub, unpicklable_fn, None, None) - self.assertRaises(ValueError, make_pool, + self.assertRaises(Exception, make_pool, host, jobs, _stub, None, unpicklable_fn, None) - self.assertRaises(ValueError, make_pool, + self.assertRaises(Exception, make_pool, host, jobs, _stub, None, None, unpicklable_fn) def test_no_close(self):
diff --git a/typ/version.py b/typ/version.py index a0cc8a3..2f9bc1b 100644 --- a/typ/version.py +++ b/typ/version.py
@@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = '0.9.5' +VERSION = '0.9.6'