Skip to content

Commit

Permalink
Fixed tests against latest pytest version
Browse files Browse the repository at this point in the history
  • Loading branch information
NyanKiyoshi committed Sep 11, 2019
1 parent 4cf0b6a commit c7b5980
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
17 changes: 6 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ python:
- "3.6"
env:
- DJANGO="1.11"
- DJANGO="2.0"
- DJANGO="2.1"
- DJANGO="2.2"
- DJANGO="master"
matrix:
include:
Expand All @@ -16,35 +15,31 @@ matrix:
- python: "3.7"
sudo: required
dist: xenial
env: DJANGO="2.0"
- python: "3.7"
sudo: required
dist: xenial
env: DJANGO="2.1"
env: DJANGO="2.2"
- python: "3.7"
sudo: required
dist: xenial
env: DJANGO="master"
allow_failures:
- python: "3.5"
env: DJANGO="2.1"
env: DJANGO="2.2"
- python: "3.5"
env: DJANGO="master"
- python: "3.6"
env: DJANGO="2.1"
env: DJANGO="2.2"
- python: "3.6"
env: DJANGO="master"
- python: "3.7"
sudo: required
dist: xenial
env: DJANGO="2.1"
env: DJANGO="2.2"
- python: "3.7"
env: DJANGO="master"
sudo: required
dist: xenial
exclude:
- python: "3.4"
env: DJANGO="2.1"
env: DJANGO="2.2"
- python: "3.4"
env: DJANGO="master"
after_success: codecov
Expand Down
6 changes: 3 additions & 3 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def test_modal_payment_form_already_processed(
provider.razorpay_client.payment.capture.assert_not_called()


def test_modal_payment_form_invalid_data(
provider, payment, valid_payment_form_data):
def test_modal_payment_form_invalid_data(provider, payment):
form = ModalPaymentForm(
provider=provider, payment=payment, data={})

with pytest.raises(KeyError, message='razorpay_payment_id'):
with pytest.raises(KeyError) as exc:
form.is_valid()
assert exc.value.args == ('razorpay_payment_id',)
provider.razorpay_client.payment.capture.assert_not_called()
11 changes: 8 additions & 3 deletions tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ def test_get_form(mocked_razor_checkout, provider, payment):


def test_get_form_invalid_data(provider, payment):
with pytest.raises(KeyError, message='razorpay_payment_id'):
with pytest.raises(KeyError) as exc:
provider.get_form(payment, data={})

assert exc.value.args == ('razorpay_payment_id',)

assert payment.captured_amount == 0
assert payment.transaction_id is None


def test_get_form_valid_data(valid_payment_form_data, provider, payment):
with pytest.raises(RedirectNeeded, message='https://success'):
with pytest.raises(RedirectNeeded) as exc:
provider.get_form(payment, data=valid_payment_form_data)

assert exc.value.args[0] == payment.get_success_url()

assert payment.save.call_count != 0
assert payment.status == PaymentStatus.CONFIRMED
assert payment.captured_amount == payment.total
Expand Down Expand Up @@ -84,7 +88,8 @@ def _raise_fake_error(*args, **kwargs):
payment.captured_amount = payment.total
provider.razorpay_client.payment.refund.side_effect = _raise_fake_error

with pytest.raises(ValueError, message='hello world'):
with pytest.raises(ValueError) as exc:
provider.refund(payment, Decimal(2220))

assert str(exc.value.args) == str(('hello world',))
assert payment.captured_amount == payment.total
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tox]
envlist = py27-django111, py{34,35,36,37}-django{111,20,21,_master}
envlist = py27-django111, py{34,35,36,37}-django{111,20,22,_master}

[testenv]
usedevelop=True
deps=
coverage
django111: django>=1.11a1,<1.12
django20: Django>=2.0a1,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
django_master: https://github.com/django/django/archive/master.tar.gz
mock
pytest
Expand All @@ -27,5 +27,5 @@ unignore_outcomes = True
DJANGO =
1.11: django111
2.0: django2.0
2.1: django2.1
2.2: django2.2
master: django_master

0 comments on commit c7b5980

Please sign in to comment.