Github action to run unit tests on windows (#1444)
This commit is contained in:
parent
e26bba80a6
commit
e6f4bcdb95
34
.github/workflows/unit_tests_windows.yml
vendored
Normal file
34
.github/workflows/unit_tests_windows.yml
vendored
Normal 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
|
@ -228,6 +228,7 @@ EVENT_NAMESPACE = get_value("EVENT_NAMESPACE")
|
|||||||
# Testing os env set by pytest when running a test case.
|
# Testing os env set by pytest when running a test case.
|
||||||
PYTEST_CURRENT_TEST = "PYTEST_CURRENT_TEST"
|
PYTEST_CURRENT_TEST = "PYTEST_CURRENT_TEST"
|
||||||
|
|
||||||
|
|
||||||
# Env modes
|
# Env modes
|
||||||
class Env(str, Enum):
|
class Env(str, Enum):
|
||||||
"""The environment modes."""
|
"""The environment modes."""
|
||||||
|
@ -65,6 +65,7 @@ if platform.system == "Windows":
|
|||||||
else:
|
else:
|
||||||
FRONTEND_POPEN_ARGS["start_new_session"] = True
|
FRONTEND_POPEN_ARGS["start_new_session"] = True
|
||||||
|
|
||||||
|
|
||||||
# borrowed from py3.11
|
# borrowed from py3.11
|
||||||
class chdir(contextlib.AbstractContextManager):
|
class chdir(contextlib.AbstractContextManager):
|
||||||
"""Non thread-safe context manager to change the current working directory."""
|
"""Non thread-safe context manager to change the current working directory."""
|
||||||
|
@ -650,7 +650,6 @@ async def test_process_event_generator(gen_state):
|
|||||||
assert update.delta == {}
|
assert update.delta == {}
|
||||||
assert update.final
|
assert update.final
|
||||||
else:
|
else:
|
||||||
|
|
||||||
assert gen_state.value == count
|
assert gen_state.value == count
|
||||||
assert update.delta == {
|
assert update.delta == {
|
||||||
"gen_state": {"value": count},
|
"gen_state": {"value": count},
|
||||||
|
@ -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.
|
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.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")
|
bun_install = mocker.patch("reflex.utils.prerequisites.install_bun")
|
||||||
remove_existing_bun_installation = mocker.patch(
|
remove_existing_bun_installation = mocker.patch(
|
||||||
@ -489,7 +489,9 @@ def test_initialize_non_existent_gitignore(tmp_path, mocker, gitignore_exists):
|
|||||||
prerequisites.initialize_gitignore()
|
prerequisites.initialize_gitignore()
|
||||||
|
|
||||||
assert gitignore_file.exists()
|
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()
|
assert set(file_content) - expected == set()
|
||||||
|
|
||||||
|
|
||||||
@ -530,6 +532,7 @@ def test_node_install_unix(tmp_path, mocker):
|
|||||||
"reflex.utils.prerequisites.subprocess.run",
|
"reflex.utils.prerequisites.subprocess.run",
|
||||||
return_value=subprocess.CompletedProcess(args="", returncode=0),
|
return_value=subprocess.CompletedProcess(args="", returncode=0),
|
||||||
)
|
)
|
||||||
|
mocker.patch("reflex.utils.prerequisites.IS_WINDOWS", False)
|
||||||
|
|
||||||
prerequisites.install_node()
|
prerequisites.install_node()
|
||||||
|
|
||||||
@ -545,6 +548,7 @@ def test_node_install_without_curl(mocker):
|
|||||||
mocker: Pytest mocker object.
|
mocker: Pytest mocker object.
|
||||||
"""
|
"""
|
||||||
mocker.patch("reflex.utils.prerequisites.path_ops.which", return_value=None)
|
mocker.patch("reflex.utils.prerequisites.path_ops.which", return_value=None)
|
||||||
|
mocker.patch("reflex.utils.prerequisites.IS_WINDOWS", False)
|
||||||
|
|
||||||
with pytest.raises(FileNotFoundError):
|
with pytest.raises(FileNotFoundError):
|
||||||
prerequisites.install_node()
|
prerequisites.install_node()
|
||||||
|
Loading…
Reference in New Issue
Block a user