Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6875985
gitignore Driver
doug-benn Dec 10, 2022
68a159f
Added webdriver_manager and set the chrome binary location on Windows
doug-benn Dec 10, 2022
ece4f32
Fixed Process ID issue on Windows
doug-benn Dec 10, 2022
def5e5b
Run the tests not on master branch
doug-benn Dec 10, 2022
92e39ef
examples/04 - file_access/file_access - Needs a 1 second delay
doug-benn Dec 10, 2022
064666a
Run github actions on Master
doug-benn Dec 10, 2022
cc28f61
Reverting as they where edited for testing
doug-benn Dec 13, 2022
eb42ab8
Reverted formatting changes and cleaned up some comments
doug-benn Dec 13, 2022
ec4e433
Fixed getting processes port number
doug-benn Dec 13, 2022
a10b105
Removed "Fix" for Mac&Linux
doug-benn Dec 13, 2022
4efbaee
Timeout to 30
doug-benn Dec 13, 2022
7665068
Timeout to 60s
doug-benn Dec 13, 2022
86a2f57
Timeout back to 5s
doug-benn Dec 13, 2022
6e12962
Timeout 60
doug-benn Dec 13, 2022
e6c490c
Getting child processes
doug-benn Dec 13, 2022
12e4235
Python 3.6 Fix
doug-benn Dec 13, 2022
9c4cfd9
Timeout?
doug-benn Dec 13, 2022
05fc06d
Python 3.6 Fix
doug-benn Dec 13, 2022
ca99588
Merge branch 'Tests' of https://github.com/doug-benn/Eel into Tests
doug-benn Dec 13, 2022
267714e
Linux & Mac subprocess changes
doug-benn Dec 14, 2022
d78d758
Running Tests!
doug-benn Dec 14, 2022
63a74d1
Formatting Test.yml
doug-benn Dec 14, 2022
c631c0a
Fixed subprocess port numbers
doug-benn Dec 13, 2022
e78a5e6
Getting child processes
doug-benn Dec 13, 2022
bbf1d90
Running Tests!
doug-benn Dec 14, 2022
5bb30a3
Formatting Test.yml
doug-benn Dec 14, 2022
194130d
Merge branch 'Tests' of https://github.com/doug-benn/Eel into Tests
doug-benn Dec 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__pycache__
dist
build
Drivers
Eel.egg-info
.tmp
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ psutil==5.9.2
pytest==7.0.1
pytest-timeout==2.1.0
selenium==3.141.0
webdriver_manager==3.7.1
14 changes: 12 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
import platform
from unittest import mock

import pytest
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from webdriver_manager.chrome import ChromeDriverManager


@pytest.fixture
Expand All @@ -14,9 +16,17 @@ def driver():
options = webdriver.ChromeOptions()
options.headless = True
capabilities = DesiredCapabilities.CHROME
capabilities['goog:loggingPrefs'] = {"browser": "ALL"}
capabilities["goog:loggingPrefs"] = {"browser": "ALL"}

driver = webdriver.Chrome(options=options, desired_capabilities=capabilities, service_log_path=os.path.devnull)
if platform.system() == "Windows":
options.binary_location = "C:/Program Files/Google/Chrome/Application/chrome.exe"

driver = webdriver.Chrome(
ChromeDriverManager().install(),
options=options,
desired_capabilities=capabilities,
service_log_path=os.path.devnull,
)

# Firefox doesn't currently supported pulling JavaScript console logs, which we currently scan to affirm that
# JS/Python can communicate in some places. So for now, we can't really use firefox/geckodriver during testing.
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
from tempfile import TemporaryDirectory, NamedTemporaryFile

from selenium import webdriver
Expand Down Expand Up @@ -47,6 +48,7 @@ def test_04_file_access(driver: webdriver.Remote):
with TemporaryDirectory() as temp_dir, NamedTemporaryFile(dir=temp_dir) as temp_file:
driver.find_element_by_id('input-box').clear()
driver.find_element_by_id('input-box').send_keys(temp_dir)
time.sleep(0.5)
driver.find_element_by_css_selector('button').click()

assert driver.find_element_by_id('file-name').text == os.path.basename(temp_file.name)
Expand Down
35 changes: 27 additions & 8 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import contextlib
import os
import sys
import platform
import subprocess
import tempfile
import time
Expand All @@ -8,15 +10,30 @@
import psutil

# Path to the test data folder.
TEST_DATA_DIR = Path(__file__).parent / 'data'
TEST_DATA_DIR = Path(__file__).parent / "data"


def get_process_listening_port(proc):
psutil_proc = psutil.Process(proc.pid)
while not any(conn.status == 'LISTEN' for conn in psutil_proc.connections()):
time.sleep(0.01)

conn = next(filter(lambda conn: conn.status == 'LISTEN', psutil_proc.connections()))
conn = None
if platform.system() == "Windows":
current_process = psutil.Process(proc.pid)
children = []
while children == []:
time.sleep(0.01)
children = current_process.children(recursive=True)
if (3, 6) <= sys.version_info < (3, 7):
children = [current_process]
for child in children:
while child.connections() == [] and not any(conn.status == "LISTEN" for conn in child.connections()):
time.sleep(0.01)

conn = next(filter(lambda conn: conn.status == "LISTEN", child.connections()))
else:
psutil_proc = psutil.Process(proc.pid)
while not any(conn.status == "LISTEN" for conn in psutil_proc.connections()):
time.sleep(0.01)

conn = next(filter(lambda conn: conn.status == "LISTEN", psutil_proc.connections()))
return conn.laddr.port


Expand All @@ -40,8 +57,10 @@ def get_eel_server(example_py, start_html):

import {os.path.splitext(os.path.basename(example_py))[0]}
""")

proc = subprocess.Popen(['python', test.name], cwd=os.path.dirname(example_py))
proc = subprocess.Popen(
[sys.executable, test.name],
cwd=os.path.dirname(example_py),
)
eel_port = get_process_listening_port(proc)

yield f"http://localhost:{eel_port}/{start_html}"
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
envlist = py36,py37,py38,py39,py310

[pytest]
timeout = 5
timeout = 30

[gh-actions]
python =
Expand All @@ -17,5 +17,5 @@ deps = -r requirements-test.txt
commands =
# this ugly hack is here because:
# https://github.com/tox-dev/tox/issues/149
pip install -q -r {toxinidir}/requirements-test.txt
{envpython} -m pytest {posargs}
pip install -q -r '{toxinidir}'/requirements-test.txt
'{envpython}' -m pytest {posargs}