Skip to content

Commit

Permalink
Merge pull request #466 from oliverkurth/topic/okurth/stable-3.3/fix-…
Browse files Browse the repository at this point in the history
…pytests

fix pytests for 3.3.x
  • Loading branch information
oliverkurth authored Feb 28, 2024
2 parents 3eee2c7 + 240c76d commit ab710b5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ci/Dockerfile.photon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM photon:latest
FROM photon:4.0

RUN tdnf update -y
RUN tdnf remove -y toybox
Expand Down
8 changes: 4 additions & 4 deletions pytests/tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_erase(utils):
def test_check_update(utils):
ret = utils.run(['tdnf', '-j', 'check-update'])
d = json.loads("\n".join(ret['stdout']))
assert type(d) == list
assert type(d) is list


def test_repolist(utils):
Expand All @@ -120,19 +120,19 @@ def test_repolist(utils):
def test_repoquery(utils):
ret = utils.run(['tdnf', '-j', 'repoquery'])
d = json.loads("\n".join(ret['stdout']))
assert type(d) == list
assert type(d) is list


def test_updateinfo(utils):
ret = utils.run(['tdnf', '-j', 'updateinfo'])
d = json.loads("\n".join(ret['stdout']))
assert type(d) == dict
assert type(d) is dict


def test_updateinfo_info(utils):
ret = utils.run(['tdnf', '-j', 'updateinfo', '--info'])
d = json.loads("\n".join(ret['stdout']))
assert type(d) == list
assert type(d) is list


def test_jsondump(utils):
Expand Down
26 changes: 19 additions & 7 deletions pytests/tests/test_tdnf_python.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,28 @@ def setup_test(utils):
sglpkgname = utils.config['sglversion_pkgname']

global config
config = utils.config['repo_path'] + '/tdnf.conf'
config = os.path.join(utils.config['repo_path'], "tdnf.conf")

path = '{builddir}/python/build/lib.linux-{arch}-{pymajor}.{pyminor}'
if not utils.config.get('installed', False):
# find path to our tdnf python module
builddir = utils.config['build_dir']
arch = os.uname().machine
pymajor = sys.version_info.major
pyminor = sys.version_info.minor

path = path.format(builddir=utils.config['build_dir'],
arch=os.uname().machine,
pymajor=str(sys.version_info.major),
pyminor=str(sys.version_info.minor))
# only support python3
assert pymajor == 3

sys.path.append(path)
if pyminor < 10:
path = f"{builddir}/python/build/lib.linux-{arch}-{pymajor}.{pyminor}"
else:
# build/lib.linux-aarch64-cpython-310/tdnf
path = f"{builddir}/python/build/lib.linux-{arch}-cpython-{pymajor}{pyminor}"

print(f"tdnf python path: {path}")

assert os.path.isdir(path)
sys.path.append(path)

global tdnf
import tdnf
Expand Down

0 comments on commit ab710b5

Please sign in to comment.