Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
Added backport for compatibility of importlib.resources.files in python
versions below 3.10
  • Loading branch information
ckunki committed Oct 23, 2024
1 parent 314dc8f commit e412616
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_db_versions_all_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
echo "All tests activated"
exit 0
else
echo "Fail, because not all tests are deactivated"
echo "Fail, because not all tests are activated"
exit 1
fi
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_python_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
exasol_version:
- "default"
python_version:
- 3.8
- 3.9
- "3.9"
- "3.10"
name: Run tests with Python ${{ matrix.python_version }} and Exasol ${{ matrix.exasol_version }}
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import re
import sys

def backport(importlib_res):
"""
Make importlib.resources.files available in Python versions below
python 3.10., see
https://github.com/exasol/integration-test-docker-environment/pull/419
"""
if not re.match(f"3\.1[0-9]", sys.version):
import importlib_resources
setattr(importlib_res, "files", importlib_resources.files)
setattr(importlib_res, "as_file", importlib_resources.as_file)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import luigi
import netaddr
import importlib.resources
import importlib.resources as importlib_res
from exasol_integration_test_docker_environment.lib.test_environment import importlib_compatibility

from docker.models.containers import Container
from docker.transport import unixconn

Expand All @@ -20,6 +22,8 @@
TestContainerParameter


importlib_compatibility.backport(importlib_res)

class SpawnTestContainer(DockerBaseTask, TestContainerParameter):
environment_name = luigi.Parameter()
test_container_name = luigi.Parameter()
Expand Down Expand Up @@ -181,7 +185,7 @@ def register_certificates(self, test_container: Container):
if self.certificate_volume_name is not None:
script_name = "install_root_certificate.sh"
script = (
importlib.resources.filename(PACKAGE_NAME)
importlib_res.files(PACKAGE_NAME)
/ "certificate_resources"
/ script_name
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import humanfriendly
import luigi
import netaddr
import importlib.resources
import importlib.resources as importlib_res

from exasol_integration_test_docker_environment.lib.test_environment import importlib_compatibility
from docker.models.containers import Container
from docker.models.volumes import Volume
from docker.client import DockerClient
Expand Down Expand Up @@ -39,6 +41,9 @@
)


importlib_compatibility.backport(importlib_res)


CERTIFICATES_MOUNT_DIR = "/certificates"
CERTIFICATES_DEFAULT_DIR = "/exa/etc/ssl/"

Expand Down Expand Up @@ -306,7 +311,7 @@ def _prepare_volume(

def _db_file(self, filename: str) -> str:
return (
importlib.resources.files(PACKAGE_NAME)
importlib_res.files(PACKAGE_NAME)
/ self.docker_db_config_resource_name
/ filename
)
Expand Down Expand Up @@ -389,3 +394,9 @@ def cleanup_task(self, success):
except Exception as e:
self.logger.error(f"Error during removing docker volume %s: %s", db_volume_name, e)




if __name__ == "__main__":
f = importlib_res.files("importlib")
print(f'{f}')

0 comments on commit e412616

Please sign in to comment.