(codefile: str, module: str, extra: str = "")
| 66 | |
| 67 | |
| 68 | def run_module(codefile: str, module: str, extra: str = ""): |
| 69 | config_file_to_cleanup = None |
| 70 | |
| 71 | # For pyright, create a pyrightconfig.json to help it find installed packages |
| 72 | # and adjust the command to use relative path |
| 73 | if module == "pyright": |
| 74 | config_dir = os.path.dirname(codefile) |
| 75 | config_file = os.path.join(config_dir, "pyrightconfig.json") |
| 76 | |
| 77 | # For editable installs, we need to find the actual source location |
| 78 | # The test component is installed as an editable package |
| 79 | project_root = os.path.dirname( |
| 80 | os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 81 | ) |
| 82 | |
| 83 | # Get the site-packages directory for standard packages |
| 84 | site_packages = sysconfig.get_path("purelib") |
| 85 | |
| 86 | # Include the directory containing the test file |
| 87 | test_file_dir = os.path.dirname(codefile) |
| 88 | |
| 89 | # Check if dash is installed as editable or regular install. |
| 90 | # If the editable source tree is unbuilt, prefer the installed package. |
| 91 | import dash |
| 92 | |
| 93 | dash_file = dash.__file__ |
| 94 | is_editable = project_root in dash_file |
| 95 | source_tree_is_built = _has_built_dash_components(project_root) |
| 96 | |
| 97 | if is_editable and source_tree_is_built: |
| 98 | # Editable install: prioritize project root |
| 99 | extra_paths = [project_root, site_packages] |
| 100 | execution_environments = [ |
| 101 | {"root": project_root, "extraPaths": extra_paths}, |
| 102 | {"root": test_file_dir, "extraPaths": extra_paths}, |
| 103 | ] |
| 104 | else: |
| 105 | # Regular installs and unbuilt editable checkouts should resolve the |
| 106 | # installed package first so generated component modules are present. |
| 107 | extra_paths = [site_packages, project_root] |
| 108 | execution_environments = [ |
| 109 | {"root": site_packages, "extraPaths": extra_paths}, |
| 110 | {"root": test_file_dir, "extraPaths": extra_paths}, |
| 111 | ] |
| 112 | |
| 113 | # Add the test component source directories |
| 114 | # They are in the @plotly subdirectory of the project root |
| 115 | test_components_dir = os.path.join(project_root, "@plotly") |
| 116 | |
| 117 | if os.path.exists(test_components_dir): |
| 118 | for component in os.listdir(test_components_dir): |
| 119 | component_path = os.path.join(test_components_dir, component) |
| 120 | if os.path.isdir(component_path): |
| 121 | extra_paths.append(component_path) |
| 122 | |
| 123 | config = { |
| 124 | "pythonVersion": f"{sys.version_info.major}.{sys.version_info.minor}", |
| 125 | "pythonPlatform": sys.platform, |
no test coverage detected
searching dependent graphs…