diff --git a/scripts/container-pre-test.sh b/scripts/container-pre-test.sh index 7c6a407..ea8c9ae 100644 --- a/scripts/container-pre-test.sh +++ b/scripts/container-pre-test.sh @@ -1,10 +1,9 @@ #!/bin/bash source /etc/os-release -# This repository is required for python3-pytest and python3-test -# on Centos Stream +# This repository is required for python3-pytest on Centos Stream if [[ $ID == "centos" ]]; then dnf config-manager --enable crb fi -dnf install -y python3-setuptools python3-pip python3-devel python3-pytest python3-test +dnf install -y python3-setuptools python3-pip python3-devel python3-pytest diff --git a/tests/test_compat.py b/tests/test_compat.py index 611e743..cc4fad4 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -10,6 +10,8 @@ """ import os +import shutil +import tempfile from iniparse import compat as ConfigParser from io import StringIO try: @@ -18,8 +20,6 @@ import collections as UserDict import unittest -from test import support as test_support - class SortedDict(UserDict.UserDict): def items(self): @@ -466,9 +466,13 @@ def test_read_returns_file_list(self): 3. Empty list is returned due to file not existing. 4. Empty list is returned since no files were passed. """ - file1 = test_support.findfile("cfgparser.1") - if not os.path.exists(file1): - file1 = test_support.findfile("configdata/cfgparser.1") + # Do not depend on the data files of CPython's 'test' package, + # which is not installed on many systems. + tmpdir = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, tmpdir) + file1 = os.path.join(tmpdir, "cfgparser.1") + with open(file1, "w") as f: + f.write("[Foo Bar]\nfoo=newbar\n") # check when we pass a mix of readable and non-readable files: cf = self.newconfig() parsed_files = cf.read([file1, "nonexistant-file"])