Github action to run unit tests on windows (#1444)

This commit is contained in:
jackie-pc 2023-07-28 11:12:01 -07:00 committed by GitHub
parent e26bba80a6
commit e6f4bcdb95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,34 @@
name: unit-tests-windows
on:
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
unit-tests:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-create: true
virtualenvs-in-project: true
- run: |
C:\Users\runneradmin\.local\bin\poetry install --no-interaction
C:\Users\runneradmin\.local\bin\poetry run pytest tests

View File

@ -228,6 +228,7 @@ EVENT_NAMESPACE = get_value("EVENT_NAMESPACE")
# Testing os env set by pytest when running a test case.
PYTEST_CURRENT_TEST = "PYTEST_CURRENT_TEST"
# Env modes
class Env(str, Enum):
"""The environment modes."""

View File

@ -65,6 +65,7 @@ if platform.system == "Windows":
else:
FRONTEND_POPEN_ARGS["start_new_session"] = True
# borrowed from py3.11
class chdir(contextlib.AbstractContextManager):
"""Non thread-safe context manager to change the current working directory."""

View File

@ -650,7 +650,6 @@ async def test_process_event_generator(gen_state):
assert update.delta == {}
assert update.final
else:
assert gen_state.value == count
assert update.delta == {
"gen_state": {"value": count},

View File

@ -274,7 +274,7 @@ def test_initialize_bun(mocker, bun_version, is_valid, prompt_input):
prompt_input: The input from user on whether to install bun.
"""
mocker.patch("reflex.utils.prerequisites.get_bun_version", return_value=bun_version)
mocker.patch("reflex.utils.prerequisites.console.ask", return_value=prompt_input)
mocker.patch("reflex.utils.prerequisites.IS_WINDOWS", False)
bun_install = mocker.patch("reflex.utils.prerequisites.install_bun")
remove_existing_bun_installation = mocker.patch(
@ -489,7 +489,9 @@ def test_initialize_non_existent_gitignore(tmp_path, mocker, gitignore_exists):
prerequisites.initialize_gitignore()
assert gitignore_file.exists()
file_content = [line.strip() for line in gitignore_file.open().readlines()]
file_content = [
line.strip() for line in gitignore_file.open().read().splitlines() if line
]
assert set(file_content) - expected == set()
@ -530,6 +532,7 @@ def test_node_install_unix(tmp_path, mocker):
"reflex.utils.prerequisites.subprocess.run",
return_value=subprocess.CompletedProcess(args="", returncode=0),
)
mocker.patch("reflex.utils.prerequisites.IS_WINDOWS", False)
prerequisites.install_node()
@ -545,6 +548,7 @@ def test_node_install_without_curl(mocker):
mocker: Pytest mocker object.
"""
mocker.patch("reflex.utils.prerequisites.path_ops.which", return_value=None)
mocker.patch("reflex.utils.prerequisites.IS_WINDOWS", False)
with pytest.raises(FileNotFoundError):
prerequisites.install_node()