# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-flaky
pkgver=3.8.0
pkgrel=1
pkgdesc='Plugin for nose or py.test that automatically reruns flaky tests'
arch=('any')
license=('Apache')
url='https://github.com/box/flaky'
depends=('python')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/box/flaky/archive/v$pkgver.tar.gz")
sha512sums=('1d62ccbb64eec3fb319f3a2abdbe6346613fbd65ae7f1fbdb62b4c72d4f5bb0bf6e5996bd7a665cf5c215037d69760fab3333cb51e7248fbb99c0ed92dd0abfd')

build() {
  cd flaky-$pkgver
  python setup.py build
}

check() {
  # Hack entry points by installing it

  cd flaky-$pkgver
  python setup.py install --root="$PWD/tmp_install" --optimize=1
  (
    export PYTHONPATH="$PWD/tmp_install/usr/lib/python3.11/site-packages:$PYTHONPATH"
    py.test -k 'example and not options' --doctest-modules test/test_pytest/
    py.test -p no:flaky test/test_pytest/test_flaky_pytest_plugin.py
    py.test --force-flaky --max-runs 2 test/test_pytest/test_pytest_options_example.py
  )
}

package() {
  cd flaky-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
}

# vim:set ts=2 sw=2 et:
