- 
                Notifications
    You must be signed in to change notification settings 
- Fork 115
test(templates): test py-shiny templates #1998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 18 commits
      Commits
    
    
            Show all changes
          
          
            24 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      d173b7c
              
                add initial placeholder file
              
              
                karangattu b75da52
              
                run it on branches starting with run-
              
              
                karangattu 86fc60f
              
                just copy over the py-shiny-templates to the examples dir instead
              
              
                karangattu 6d8403c
              
                Add dependencies required by example apps
              
              
                karangattu c119aa9
              
                check for shiny-output-error
              
              
                karangattu 35ebec9
              
                linting issues
              
              
                karangattu 68edee6
              
                skip safe exception tests for output errors
              
              
                karangattu 37df231
              
                ignore global_pyplot expected output error
              
              
                karangattu b208724
              
                add relevant comments
              
              
                karangattu aaa2ee4
              
                Merge branch 'main' into run-py-shiny-template-tests
              
              
                karangattu 96771ad
              
                install deps before running the tests
              
              
                karangattu 1dfd712
              
                fix linting issues
              
              
                karangattu 3614b3f
              
                see if this fixes pyright issues
              
              
                karangattu 5286042
              
                Merge branch 'main' into run-py-shiny-template-tests
              
              
                karangattu 0de7da4
              
                Remove unused import from app.py
              
              
                karangattu ec648cc
              
                Add new allowed deprecation warnings for cufflinks
              
              
                karangattu c22da78
              
                Skip template dependency install and tests on Python 3.9
              
              
                karangattu ec26fe1
              
                Skip test on Python 3.9 due to scikit-learn version
              
              
                karangattu 960fc91
              
                Adjust make command to install deps
              
              
                schloerke ae24fc2
              
                Discard changes to tests/playwright/shiny/components/data_frame/edit/…
              
              
                schloerke 17a2825
              
                Update pyproject.toml
              
              
                schloerke 6dc0c9b
              
                default timeout is ok
              
              
                schloerke 9a5e2a0
              
                Merge branch 'run-py-shiny-template-tests' of https://github.com/posi…
              
              
                schloerke 7d869e5
              
                fix langchain install dep hell
              
              
                schloerke File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -4,7 +4,7 @@ | |
| from pathlib import PurePath | ||
| from typing import Literal | ||
|  | ||
| from playwright.sync_api import ConsoleMessage, Page | ||
| from playwright.sync_api import ConsoleMessage, Page, expect | ||
|  | ||
| from shiny.run import ShinyAppProc, run_shiny_app | ||
|  | ||
|  | @@ -15,6 +15,9 @@ | |
| reruns = 1 if is_interactive else 3 | ||
| reruns_delay = 0 | ||
|  | ||
| SHINY_INIT_TIMEOUT = 30_000 | ||
| ERROR_ELEMENT_TIMEOUT = 1_000 | ||
|  | ||
|  | ||
| def get_apps(path: str) -> typing.List[str]: | ||
| full_path = pyshiny_root / path | ||
|  | @@ -91,11 +94,20 @@ def get_apps(path: str) -> typing.List[str]: | |
| "FutureWarning: use_inf_as_na option is deprecated", | ||
| "pd.option_context('mode.use_inf_as_na", # continutation of line above, | ||
| "RuntimeWarning: invalid value encountered in dot", # some groups didn't have enough data points to create a meaningful line | ||
| "DatetimeIndex.format is deprecated and will be removed in a future version. Convert using index.astype(str) or index.map(formatter) instead.", # cufflinks package is using this method | ||
| "Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`", # cufflinks package is using this method | ||
| ] | ||
| app_allow_js_errors: typing.Dict[str, typing.List[str]] = { | ||
| "examples/brownian": ["Failed to acquire camera feed:"], | ||
| } | ||
|  | ||
| # Check for Shiny output errors, except for known exception cases | ||
| app_allow_output_error = [ | ||
| "shiny/api-examples/SafeException/app-express.py", | ||
| "shiny/api-examples/SafeException/app-core.py", | ||
| "examples/global_pyplot/app.py", | ||
| ] | ||
|  | ||
|  | ||
| # Altered from `shinytest2:::app_wait_for_idle()` | ||
| # https://github.com/rstudio/shinytest2/blob/b8fdce681597e9610fc078aa6e376134c404f3bd/R/app-driver-wait.R | ||
|  | @@ -251,3 +263,8 @@ def on_console_msg(msg: ConsoleMessage) -> None: | |
| + " had JavaScript console errors!\n" | ||
| + "* ".join(console_errors) | ||
| ) | ||
|  | ||
| if ex_app_path not in app_allow_output_error: | ||
| # Ensure there are no output errors present | ||
| error_locator = page.locator(".shiny-output-error") | ||
| expect(error_locator).to_have_count(0, timeout=ERROR_ELEMENT_TIMEOUT) | ||
|          | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import sys | ||
| from pathlib import Path | ||
|  | ||
| import pytest | ||
| from conftest import here_root | ||
| from example_apps import get_apps, reruns, reruns_delay, validate_example | ||
| from playwright.sync_api import Page | ||
|  | ||
| if not Path(here_root / "py-shiny-templates").exists(): | ||
| pytest.skip( | ||
| "./py-shiny-templates dir is not available. Skipping test.", | ||
| allow_module_level=True, | ||
| ) | ||
|  | ||
|  | ||
| @pytest.mark.skipif( | ||
| sys.version_info[:2] == (3, 9), | ||
| reason="Skipping test for Python 3.9 since scikit-learn pinned version is only supported on Python 3.10+", | ||
| ) | ||
| @pytest.mark.only_browser("chromium") | ||
| @pytest.mark.flaky(reruns=reruns, reruns_delay=reruns_delay) | ||
| @pytest.mark.parametrize("ex_app_path", get_apps("py-shiny-templates")) | ||
| def test_external_templates(page: Page, ex_app_path: str) -> None: | ||
| validate_example(page, ex_app_path) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.