Fixture for an app that can be compiled. Args: tmp_path: Temporary path. forked_registration_context: Isolated state/event registration context. Yields: Tuple containing (app instance, Path to ".web" directory) The working directory is set to the app dir (p
(
tmp_path: Path,
forked_registration_context: RegistrationContext,
)
| 2030 | |
| 2031 | @pytest.fixture |
| 2032 | def compilable_app( |
| 2033 | tmp_path: Path, |
| 2034 | forked_registration_context: RegistrationContext, |
| 2035 | ) -> Generator[tuple[App, Path], None, None]: |
| 2036 | """Fixture for an app that can be compiled. |
| 2037 | |
| 2038 | Args: |
| 2039 | tmp_path: Temporary path. |
| 2040 | forked_registration_context: Isolated state/event registration context. |
| 2041 | |
| 2042 | Yields: |
| 2043 | Tuple containing (app instance, Path to ".web" directory) |
| 2044 | |
| 2045 | The working directory is set to the app dir (parent of .web), |
| 2046 | allowing app.compile() to be called. |
| 2047 | """ |
| 2048 | app_path = tmp_path / "app" |
| 2049 | web_dir = app_path / ".web" |
| 2050 | web_dir.mkdir(parents=True) |
| 2051 | (web_dir / constants.PackageJson.PATH).touch() |
| 2052 | (web_dir / constants.Dirs.POSTCSS_JS).touch() |
| 2053 | (web_dir / constants.Dirs.POSTCSS_JS).write_text( |
| 2054 | """ |
| 2055 | module.exports = { |
| 2056 | plugins: { |
| 2057 | "postcss-import": {}, |
| 2058 | autoprefixer: {}, |
| 2059 | }, |
| 2060 | }; |
| 2061 | """, |
| 2062 | ) |
| 2063 | reload_state_module(__name__) |
| 2064 | app = App(theme=None) |
| 2065 | app._get_frontend_packages = unittest.mock.Mock() |
| 2066 | with chdir(app_path): |
| 2067 | yield app, web_dir |
| 2068 | |
| 2069 | |
| 2070 | EVENT_LOOP_CONTEXT_HOOK = ( |
nothing calls this directly
no test coverage detected