diff --git a/.github/actions/test-python/action.yml b/.github/actions/test-python/action.yml index b54aa40d..d797e9ca 100644 --- a/.github/actions/test-python/action.yml +++ b/.github/actions/test-python/action.yml @@ -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 @@ -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 diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml index 2daacc27..f061f60e 100644 --- a/.github/workflows/test-results.yml +++ b/.github/workflows/test-results.yml @@ -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: diff --git a/python/test/spark_common.py b/python/test/spark_common.py index 44df2eb1..019cce45 100644 --- a/python/test/spark_common.py +++ b/python/test/spark_common.py @@ -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 @@ -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 diff --git a/python/test/test_diff.py b/python/test/test_diff.py index 108e2672..91f0ef25 100644 --- a/python/test/test_diff.py +++ b/python/test/test_diff.py @@ -378,4 +378,4 @@ def test_diff_comparators(self): if __name__ == '__main__': - SparkTest.main() + SparkTest.main(__file__) diff --git a/python/test/test_histogram.py b/python/test/test_histogram.py index 1856fb37..0f58d848 100644 --- a/python/test/test_histogram.py +++ b/python/test/test_histogram.py @@ -49,4 +49,4 @@ def test_histogram_with_floats(self): if __name__ == '__main__': - SparkTest.main() + SparkTest.main(__file__) diff --git a/python/test/test_job_description.py b/python/test/test_job_description.py index 2aa820b6..15630a43 100644 --- a/python/test/test_job_description.py +++ b/python/test/test_job_description.py @@ -67,4 +67,4 @@ def test_append_job_description(self): if __name__ == '__main__': - SparkTest.main() + SparkTest.main(__file__) diff --git a/python/test/test_package.py b/python/test/test_package.py index 7cbdbf34..2a496fd3 100644 --- a/python/test/test_package.py +++ b/python/test/test_package.py @@ -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') @@ -260,4 +260,4 @@ def test_install_poetry_project_not_supported(self): if __name__ == '__main__': - SparkTest.main() + SparkTest.main(__file__) diff --git a/python/test/test_parquet.py b/python/test/test_parquet.py index 8988ccea..f81f6215 100644 --- a/python/test/test_parquet.py +++ b/python/test/test_parquet.py @@ -54,4 +54,4 @@ def test_parquet_partitions(self): if __name__ == '__main__': - SparkTest.main() + SparkTest.main(__file__) diff --git a/python/test/test_row_number.py b/python/test/test_row_number.py index 67da1759..8a99f937 100644 --- a/python/test/test_row_number.py +++ b/python/test/test_row_number.py @@ -132,4 +132,4 @@ def test_row_numbers_row_number_col_name(self): if __name__ == '__main__': - SparkTest.main() + SparkTest.main(__file__)