Skip to content

Commit

Permalink
Merge pull request #605 from benjaoming/replace-ugettext
Browse files Browse the repository at this point in the history
Remove reversion from Django 4 (alpha) tests
  • Loading branch information
benjaoming committed Feb 3, 2021
2 parents 852353f + 1a22a74 commit 8014bed
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ line_length = 120
combine_as_imports = true
known_django = django
known_first_party = tests, djmoney, moneyed
known_third_party = moneyed,pytest,rest_framework,reversion,setuptools,sphinx_rtd_theme
known_third_party = moneyed,pytest,rest_framework,setuptools,sphinx_rtd_theme
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
include_trailing_comma = true
multi_line_output = 3
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def run_tests(self):
"pytest-django",
"pytest-pythonpath",
"pytest-cov",
"django-reversion",
"mixer",
]

Expand Down
1 change: 0 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"django.contrib.sites",
"djmoney",
"djmoney.contrib.exchange",
"reversion",
"tests.testapp",
]

Expand Down
4 changes: 4 additions & 0 deletions tests/settings_reversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .settings import * # noqa


INSTALLED_APPS.append("reversion") # noqa
8 changes: 6 additions & 2 deletions tests/test_reversion.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from django.conf import settings

import pytest
from reversion.models import Version
from reversion.revisions import create_revision

from djmoney.money import Money

from .testapp.models import RevisionedModel


@pytest.mark.django_db
@pytest.mark.skipif("reversion" not in settings.INSTALLED_APPS, reason="django-reversion not enabled")
def test_that_can_safely_restore_deleted_object():
from reversion.models import Version
from reversion.revisions import create_revision

amount = Money(100, "GHS")
with create_revision():
instance = RevisionedModel.objects.create(amount=amount)
Expand Down
10 changes: 8 additions & 2 deletions tests/testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
"""
from decimal import Decimal

from django.conf import settings
from django.core.validators import MinValueValidator
from django.db import models

from reversion.revisions import register

from djmoney.models.fields import MoneyField
from djmoney.models.managers import money_manager, understands_money
from djmoney.models.validators import MaxMoneyValidator, MinMoneyValidator
from djmoney.money import Money
from moneyed import Money as OldMoney


# Import reversion if configured
if "reversion" in settings.INSTALLED_APPS:
from reversion.revisions import register
else:
register = lambda _: None # noqa


class ModelWithVanillaMoneyField(models.Model):
money = MoneyField(max_digits=10, decimal_places=2, default=0.0)
second_money = MoneyField(max_digits=10, decimal_places=2, default=0.0, default_currency="EUR")
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ deps =
django30: {[django]3.0.x}
django31: {[django]3.1.x}
django_master: {[django]master}
commands = py.test --ds=tests.settings --cov=./djmoney {posargs} -W error::DeprecationWarning
commands = py.test --ds=tests.settings_reversion --cov=./djmoney {posargs} -W error::DeprecationWarning
usedevelop = false

[testenv:django_master-py{39,38,37,36,py3}]
commands = py.test --ds=tests.settings --cov=./djmoney {posargs} -W error::DeprecationWarning

[testenv:lint]
deps =
flake8
Expand Down Expand Up @@ -59,7 +62,6 @@ commands =
djangorestframework>=3.12.0
master =
https://github.com/django/django/tarball/master
django-reversion>=3.0.8
djangorestframework>=3.12.0

[testenv:no_rest_framework]
Expand Down

0 comments on commit 8014bed

Please sign in to comment.