diff --git a/sdks/python/apache_beam/io/filesystem_test.py b/sdks/python/apache_beam/io/filesystem_test.py index 1c6cdd7a87ed..38ddf262e649 100644 --- a/sdks/python/apache_beam/io/filesystem_test.py +++ b/sdks/python/apache_beam/io/filesystem_test.py @@ -212,3 +212,8 @@ def test_tell(self): self.assertEqual(current_offset, readable.tell()) if not line: break + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/io/filesystemio_test.py b/sdks/python/apache_beam/io/filesystemio_test.py index 2f1de9dcedac..5609113abcce 100644 --- a/sdks/python/apache_beam/io/filesystemio_test.py +++ b/sdks/python/apache_beam/io/filesystemio_test.py @@ -183,3 +183,8 @@ def test_pipe_stream(self): parent_conn.send_bytes(data) parent_conn.close() child_thread.join() + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/io/filesystems_test.py b/sdks/python/apache_beam/io/filesystems_test.py index d8cc97115508..34ed8d2e10e0 100644 --- a/sdks/python/apache_beam/io/filesystems_test.py +++ b/sdks/python/apache_beam/io/filesystems_test.py @@ -231,3 +231,8 @@ def test_delete_error(self): r'^Delete operation failed') as error: FileSystems.delete([path1]) self.assertEqual(error.exception.exception_details.keys(), [path1]) + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/io/gcp/gcsfilesystem_test.py b/sdks/python/apache_beam/io/gcp/gcsfilesystem_test.py index bc55b08f7dda..d2efcdeed863 100644 --- a/sdks/python/apache_beam/io/gcp/gcsfilesystem_test.py +++ b/sdks/python/apache_beam/io/gcp/gcsfilesystem_test.py @@ -340,3 +340,8 @@ def test_delete_error(self, mock_gcsio): self.fs.delete(files) self.assertEqual(error.exception.exception_details, expected_results) gcsio_mock.delete_batch.assert_called() + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/io/hadoopfilesystem_test.py b/sdks/python/apache_beam/io/hadoopfilesystem_test.py index 2ba1da26468b..91d19a9047c1 100644 --- a/sdks/python/apache_beam/io/hadoopfilesystem_test.py +++ b/sdks/python/apache_beam/io/hadoopfilesystem_test.py @@ -493,3 +493,8 @@ def test_delete_error(self): r'^Delete operation failed .* %s' % path1): self.fs.delete([url1, url2]) self.assertFalse(self.fs.exists(url2)) + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/io/localfilesystem_test.py b/sdks/python/apache_beam/io/localfilesystem_test.py index 29b68f61c34d..0e13caa926b7 100644 --- a/sdks/python/apache_beam/io/localfilesystem_test.py +++ b/sdks/python/apache_beam/io/localfilesystem_test.py @@ -253,3 +253,8 @@ def test_delete_error(self): r'^Delete operation failed') as error: self.fs.delete([path1]) self.assertEqual(error.exception.exception_details.keys(), [path1]) + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/options/value_provider_test.py b/sdks/python/apache_beam/options/value_provider_test.py index 88b5efa43fe4..810f3be6b96c 100644 --- a/sdks/python/apache_beam/options/value_provider_test.py +++ b/sdks/python/apache_beam/options/value_provider_test.py @@ -182,3 +182,8 @@ def _add_argparse_args(cls, parser): options = UserDefinedOptions(['--vpt_vp_arg13', 'a', '--vpt_vp_arg14', '2']) self.assertEqual(options.vpt_vp_arg13.get(), 'a') self.assertEqual(options.vpt_vp_arg14.get(), 2) + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/transforms/create_test.py b/sdks/python/apache_beam/transforms/create_test.py index e5863295ac17..754fb31abcd3 100644 --- a/sdks/python/apache_beam/transforms/create_test.py +++ b/sdks/python/apache_beam/transforms/create_test.py @@ -120,3 +120,8 @@ def test_create_source_progress(self): self.assertEqual( expected_split_points_report, split_points_report) + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/apache_beam/transforms/util_test.py b/sdks/python/apache_beam/transforms/util_test.py index a829c72a62b7..d6199030b78e 100644 --- a/sdks/python/apache_beam/transforms/util_test.py +++ b/sdks/python/apache_beam/transforms/util_test.py @@ -328,3 +328,8 @@ def test_reshuffle_streaming_global_window(self): assert_that(after_reshuffle, equal_to(expected_data), label='after reshuffle') pipeline.run() + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + unittest.main() diff --git a/sdks/python/run_pylint.sh b/sdks/python/run_pylint.sh index 8696a8272d4e..e3f9a8e267fc 100755 --- a/sdks/python/run_pylint.sh +++ b/sdks/python/run_pylint.sh @@ -64,6 +64,7 @@ echo "Running pycodestyle for module $MODULE:" pycodestyle "$MODULE" --exclude="$FILES_TO_IGNORE" echo "Running flake8 for module $MODULE:" flake8 $MODULE --count --select=E999 --show-source --statistics + echo "Running isort for module $MODULE:" # Skip files where isort is behaving weirdly ISORT_EXCLUDED=( @@ -87,6 +88,7 @@ done pushd "$MODULE" isort -p apache_beam --line-width 120 --check-only --order-by-type --combine-star --force-single-line-imports --diff ${SKIP_PARAM} popd + FUTURIZE_EXCLUDED=( "typehints.py" "pb2" @@ -105,3 +107,14 @@ if [ "$count" != "0" ]; then exit 1 fi echo "No future changes needed" + +echo "Checking unittest.main for module ${MODULE}:" +TESTS_MISSING_MAIN=$(find ${MODULE} | grep '\.py$' | xargs grep -l '^import unittest$' | xargs grep -L unittest.main) +if [ -n "${TESTS_MISSING_MAIN}" ]; then + echo -e "\nThe following files are missing a call to unittest.main():" + for FILE in ${TESTS_MISSING_MAIN}; do + echo " ${FILE}" + done + echo + exit 1 +fi