#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=python-pytest
pkgver=7.2.0
pkgrel=04
pkgdesc="Simple powerful testing with Python"
arch=('any')
url="https://pytest.org/"
depends=('python-attrs' 'python-exceptiongroup' 'python-iniconfig'
         'python-packaging' 'python-pluggy' 'python-tomli')
makedepends=('python-build' 'python-installer' 'python-setuptools'
             'python-wheel')
checkdepends=('python-argcomplete' 'python-hypothesis' 'python-nose'
              'python-requests' 'python-xmlschema'
              # Unlisted, but actually used. Check again after a while:
              'lsof' 'python-asynctest' 'python-decorator' 'python-docutils'
              'python-jinja' 'python-numpy' 'python-pexpect' 'python-pygments'
              'python-pytest-xdist' 'python-twisted')
source=("https://files.pythonhosted.org/packages/source/p/pytest/pytest-$pkgver.tar.gz"
        'pytest-fix_test_raising_repr_test.patch::https://github.com/pytest-dev/pytest/commit/54d5a63d1485110015665ece1065982407394517.patch')

# Remove dep on setuptools_scm
prepare() {
  cd pytest-$pkgver
  sed -i "/^\[metadata\]/a version = $pkgver
  /setuptools-scm/d" setup.cfg
  sed -i '/setuptools-scm\|wheel/d
  /\[tool.setuptools_scm\]/,/^$/d' pyproject.toml
  patch --forward --strip=1 --input=../pytest-fix_test_raising_repr_test.patch
}

build() {
  cd pytest-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd pytest-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  # https://github.com/pytest-dev/pytest/issues/10042
  test-env/bin/python -m pytest -o xfail_strict=False
}

package() {
  cd pytest-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/pytest-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

#---- license gpg-key sha256sums ----

license=('MIT')

sha256sums=(c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59 # pytest-7.2.0.tar.gz
	0b9325fd0ab8789f3dbe82c09cb9a9cfd2aa52383925d4b8c699203c7c4284fd) # pytest-fix_test_raising_repr_test.patch
 
 
