Skip to content

Commit

Permalink
Fix skipped poetry install tests (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi authored Dec 15, 2023
1 parent 066c16f commit ebac65f
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
11 changes: 9 additions & 2 deletions .github/actions/test-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,23 @@ runs:

- name: Prepare poetry tests
run: |
# install poetry in venv
python -m venv .poetry-venv
.poetry-venv/bin/python -m pip install poetry
# env var needed by poetry tests
echo "POETRY_PYTHON=$PWD/.poetry-venv/bin/python" | tee -a "$GITHUB_ENV"
# clone example poetry project
git clone https://github.com/Textualize/rich.git .rich
cd .rich
git reset --hard 20024635c06c22879fd2fd1e380ec4cccd9935dd
# env var needed by poetry tests
echo "RICH_SOURCES=$PWD" | tee -a "$GITHUB_ENV"
shell: bash

- name: Python Unit Tests
env:
PYTHONPATH: python:python/test
RICH_SOURCES: .rich
POETRY_PYTHON: .poetry-venv/bin/python
run: |
python -m pytest python/test --junit-xml test-results/pytest-$(date +%s.%N)-$RANDOM.xml
shell: bash
Expand All @@ -99,6 +104,8 @@ runs:
shell: bash

- name: Python Integration Tests
env:
PYTHONPATH: python:python/test
run: |
find python/test -name 'test*.py' > tests
while read test
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ jobs:
name_is_regexp: true
path: artifacts

- name: artifacts
run: find artifacts | sort
shell: bash

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions python/test/spark_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import contextlib
import logging
import os
import subprocess
import sys
import unittest
from pathlib import Path

from pyspark import SparkConf
from pyspark.sql import SparkSession
Expand All @@ -38,12 +38,13 @@ def spark_session():
class SparkTest(unittest.TestCase):

@staticmethod
def main():
def main(file: str):
if len(sys.argv) == 2:
# location to store test results provided, this requires package unittest-xml-reporting
import xmlrunner

unittest.main(
module=f'test.{Path(file).name[:-3]}',
testRunner=xmlrunner.XMLTestRunner(output=sys.argv[1]),
argv=sys.argv[:1],
# these make sure that some options that are not applicable
Expand Down
2 changes: 1 addition & 1 deletion python/test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,4 @@ def test_diff_comparators(self):


if __name__ == '__main__':
SparkTest.main()
SparkTest.main(__file__)
2 changes: 1 addition & 1 deletion python/test/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ def test_histogram_with_floats(self):


if __name__ == '__main__':
SparkTest.main()
SparkTest.main(__file__)
2 changes: 1 addition & 1 deletion python/test/test_job_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ def test_append_job_description(self):


if __name__ == '__main__':
SparkTest.main()
SparkTest.main(__file__)
4 changes: 2 additions & 2 deletions python/test/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def test_install_poetry_project(self):
expected = [Row("👍")] * 10
self.assertEqual(expected, actual)

@skipIf(__version__.startswith('3.0.'), 'install_pip_package not supported for Spark 3.0')
@skipIf(__version__.startswith('3.0.'), 'install_poetry_project not supported for Spark 3.0')
# provide an environment variable with path to the python binary of a virtual env that has poetry installed
@skipIf(POETRY_PYTHON_ENV not in os.environ, f'Environment variable {POETRY_PYTHON_ENV} pointing to '
f'virtual env python with poetry required')
Expand All @@ -260,4 +260,4 @@ def test_install_poetry_project_not_supported(self):


if __name__ == '__main__':
SparkTest.main()
SparkTest.main(__file__)
2 changes: 1 addition & 1 deletion python/test/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def test_parquet_partitions(self):


if __name__ == '__main__':
SparkTest.main()
SparkTest.main(__file__)
2 changes: 1 addition & 1 deletion python/test/test_row_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ def test_row_numbers_row_number_col_name(self):


if __name__ == '__main__':
SparkTest.main()
SparkTest.main(__file__)

0 comments on commit ebac65f

Please sign in to comment.