diff --git a/.github/workflows/unit_tests_windows.yml b/.github/workflows/unit_tests_windows.yml new file mode 100644 index 000000000..e61786d85 --- /dev/null +++ b/.github/workflows/unit_tests_windows.yml @@ -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 diff --git a/reflex/constants.py b/reflex/constants.py index 4a9a29d91..d4f7725ae 100644 --- a/reflex/constants.py +++ b/reflex/constants.py @@ -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.""" diff --git a/reflex/testing.py b/reflex/testing.py index a00de8c72..fb832674e 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -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.""" diff --git a/tests/test_state.py b/tests/test_state.py index 12da3635f..c41040312 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -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}, diff --git a/tests/test_utils.py b/tests/test_utils.py index e62d82b3f..e2cd9ba8e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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()