From ae3ff0a8ce71f6be4a782481e2f6827cf9e99bd9 Mon Sep 17 00:00:00 2001 From: Matt Zimmerman Date: Fri, 7 Jan 2022 07:45:27 -0800 Subject: [PATCH] Skip empty test directories in gen_requirements_all (#62970) --- script/gen_requirements_all.py | 20 +++++--------------- tests/components/amberelectric/__init__.py | 1 + 2 files changed, 6 insertions(+), 15 deletions(-) create mode 100644 tests/components/amberelectric/__init__.py diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 02ef8d929da..117e5230c52 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -136,22 +136,12 @@ def has_tests(module: str): """Test if a module has tests. Module format: homeassistant.components.hue - Test if exists: tests/components/hue + Test if exists: tests/components/hue/__init__.py """ - path = Path(module.replace(".", "/").replace("homeassistant", "tests")) - if not path.exists(): - return False - - if not path.is_dir(): - return True - - # Dev environments might have stale directories around - # from removed tests. Check for that. - content = [f.name for f in path.glob("*")] - - # Directories need to contain more than `__pycache__` - # to exist in Git and so be seen by CI. - return content != ["__pycache__"] + path = ( + Path(module.replace(".", "/").replace("homeassistant", "tests")) / "__init__.py" + ) + return path.exists() def explore_module(package, explore_children): diff --git a/tests/components/amberelectric/__init__.py b/tests/components/amberelectric/__init__.py new file mode 100644 index 00000000000..9eae18c65aa --- /dev/null +++ b/tests/components/amberelectric/__init__.py @@ -0,0 +1 @@ +"""Tests for the amberelectric integration."""