Spaces:
Sleeping
Sleeping
rmm
commited on
Commit
·
f10ce15
1
Parent(s):
6bc8af8
chore: added custom marker to slow (>20s) test, updated CI to skip
Browse files- on PR we run all tests, including the slow one(s)
- on push we just do the faster ones
- registered marks in pytest.ini
- .github/workflows/python-pycov-onPR.yml +2 -0
- .github/workflows/python-pytest.yml +2 -2
- pytest.ini +3 -0
- src/input/input_handling.py +1 -0
- tests/test_demo_input_sidebar.py +2 -1
- tests/test_main.py +1 -0
.github/workflows/python-pycov-onPR.yml
CHANGED
|
@@ -24,6 +24,8 @@ jobs:
|
|
| 24 |
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi
|
| 25 |
|
| 26 |
- name: Build coverage files for mishakav commenter action
|
|
|
|
|
|
|
| 27 |
run: |
|
| 28 |
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests/ | tee pytest-coverage.txt
|
| 29 |
echo "working dir:" && pwd
|
|
|
|
| 24 |
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi
|
| 25 |
|
| 26 |
- name: Build coverage files for mishakav commenter action
|
| 27 |
+
# note this will run all tests, including the slow end2end ones
|
| 28 |
+
# - this action is only on PR; the slow ones are skipped on push.
|
| 29 |
run: |
|
| 30 |
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests/ | tee pytest-coverage.txt
|
| 31 |
echo "working dir:" && pwd
|
.github/workflows/python-pytest.yml
CHANGED
|
@@ -31,6 +31,6 @@ jobs:
|
|
| 31 |
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
| 32 |
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
| 33 |
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
| 34 |
-
- name:
|
| 35 |
run: |
|
| 36 |
-
pytest
|
|
|
|
| 31 |
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
| 32 |
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
| 33 |
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
| 34 |
+
- name: Run quick tests with pytest
|
| 35 |
run: |
|
| 36 |
+
pytest -m "not end2end_slow"
|
pytest.ini
CHANGED
|
@@ -3,3 +3,6 @@ pythonpath = "src"
|
|
| 3 |
testpaths =
|
| 4 |
tests
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
testpaths =
|
| 4 |
tests
|
| 5 |
|
| 6 |
+
markers =
|
| 7 |
+
component:
|
| 8 |
+
end2end_slow:
|
src/input/input_handling.py
CHANGED
|
@@ -127,6 +127,7 @@ def buffer_uploaded_files():
|
|
| 127 |
print(f"[D] processing {ix}th file {filename}. {file.file_id} {file.type} {file.size}")
|
| 128 |
# image to np and hash both require reading the file so do together
|
| 129 |
image, image_hash = load_file_and_hash(file)
|
|
|
|
| 130 |
|
| 131 |
filenames.append(filename)
|
| 132 |
image_hashes.append(image_hash)
|
|
|
|
| 127 |
print(f"[D] processing {ix}th file {filename}. {file.file_id} {file.type} {file.size}")
|
| 128 |
# image to np and hash both require reading the file so do together
|
| 129 |
image, image_hash = load_file_and_hash(file)
|
| 130 |
+
print(f" [D] {ix}th file {filename} hash: {image_hash}")
|
| 131 |
|
| 132 |
filenames.append(filename)
|
| 133 |
image_hashes.append(image_hash)
|
tests/test_demo_input_sidebar.py
CHANGED
|
@@ -172,6 +172,7 @@ def verify_metadata_in_demo_display(at:AppTest, num_files:int):
|
|
| 172 |
if num_files >= 3:
|
| 173 |
assert at.text_area(key='metadata_2').value == exp2
|
| 174 |
|
|
|
|
| 175 |
def test_no_input_no_interaction():
|
| 176 |
|
| 177 |
# zero test: no inputs
|
|
@@ -218,7 +219,7 @@ def test_no_input_no_interaction():
|
|
| 218 |
# assert "container_file_uploader_id" in at.session_state
|
| 219 |
# assert "container_metadata_inputs_id" in at.session_state
|
| 220 |
|
| 221 |
-
|
| 222 |
@patch("streamlit.file_uploader")
|
| 223 |
def test_two_input_files_realdata(mock_file_rv: MagicMock, mock_uploadedFile_List_ImageData):
|
| 224 |
# many test: list of 2 inputs
|
|
|
|
| 172 |
if num_files >= 3:
|
| 173 |
assert at.text_area(key='metadata_2').value == exp2
|
| 174 |
|
| 175 |
+
@pytest.mark.component
|
| 176 |
def test_no_input_no_interaction():
|
| 177 |
|
| 178 |
# zero test: no inputs
|
|
|
|
| 219 |
# assert "container_file_uploader_id" in at.session_state
|
| 220 |
# assert "container_metadata_inputs_id" in at.session_state
|
| 221 |
|
| 222 |
+
@pytest.mark.component
|
| 223 |
@patch("streamlit.file_uploader")
|
| 224 |
def test_two_input_files_realdata(mock_file_rv: MagicMock, mock_uploadedFile_List_ImageData):
|
| 225 |
# many test: list of 2 inputs
|
tests/test_main.py
CHANGED
|
@@ -39,6 +39,7 @@ def nooop():
|
|
| 39 |
raise RuntimeError
|
| 40 |
pass
|
| 41 |
|
|
|
|
| 42 |
@patch("streamlit.file_uploader")
|
| 43 |
def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedFile_List_ImageData):
|
| 44 |
# this test goes through several stages of the workflow
|
|
|
|
| 39 |
raise RuntimeError
|
| 40 |
pass
|
| 41 |
|
| 42 |
+
@pytest.mark.end2end_slow
|
| 43 |
@patch("streamlit.file_uploader")
|
| 44 |
def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedFile_List_ImageData):
|
| 45 |
# this test goes through several stages of the workflow
|