Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-django-money for
openSUSE:Factory checked in at 2024-07-01 11:20:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-money (Old)
and /work/SRC/openSUSE:Factory/.python-django-money.new.18349 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-money"
Mon Jul 1 11:20:02 2024 rev:9 rq:1184011 version:3.5.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-django-money/python-django-money.changes
2023-12-28 23:02:52.905552701 +0100
+++
/work/SRC/openSUSE:Factory/.python-django-money.new.18349/python-django-money.changes
2024-07-01 11:20:40.843738935 +0200
@@ -1,0 +2,13 @@
+Sat Jun 29 16:39:04 UTC 2024 - Dirk Müller <[email protected]>
+
+- update to 3.5.2:
+ * django-rest-framework: Fix regression from 3.5
+ * If you generated MoneyField migrations in the previous series
+ 3.4.x, you may have to manually edit subsequent migrations.
+ * Revert 3.4 patch, meaning that auto-generated CurrencyField
+ is once again part of migrations
+ * django-rest-framework: MinMoneyValidator and
+ MaxMoneyValidator fixed, may require default_currency defined
+ * Django 5.0 support
+
+-------------------------------------------------------------------
Old:
----
django-money-3.4.1.tar.gz
New:
----
django-money-3.5.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-money.spec ++++++
--- /var/tmp/diff_new_pack.XeIfdS/_old 2024-07-01 11:20:41.499762832 +0200
+++ /var/tmp/diff_new_pack.XeIfdS/_new 2024-07-01 11:20:41.503762978 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-django-money
#
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%define skip_python2 1
%define skip_python36 1
Name: python-django-money
-Version: 3.4.1
+Version: 3.5.2
Release: 0
Summary: Django support for using money and currency fields
License: BSD-3-Clause
++++++ django-money-3.4.1.tar.gz -> django-money-3.5.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/.github/workflows/main.yml
new/django-money-3.5.2/.github/workflows/main.yml
--- old/django-money-3.4.1/.github/workflows/main.yml 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/.github/workflows/main.yml 2024-05-07
23:30:47.000000000 +0200
@@ -7,7 +7,7 @@
name: Generic pre-commit checks
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-python@v4
@@ -20,7 +20,7 @@
name: docs
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-python@v4
@@ -34,68 +34,30 @@
strategy:
matrix:
include:
- - python: pypy-3.8
- tox_env: django22-pypy3
- - python: pypy-3.8
- tox_env: django32-pypy3
- - python: pypy-3.8
- tox_env: django40-pypy3
- - python: '3.7'
- tox_env: django22-py37
- - python: '3.7'
- tox_env: django32-py37
- - python: '3.8'
- tox_env: django22-py38
- - python: '3.8'
- tox_env: django32-py38
- - python: '3.8'
- tox_env: django40-py38
- - python: '3.8'
- tox_env: django41-py38
- python: '3.8'
tox_env: django42-py38
- python: '3.9'
- tox_env: django22-py39
- - python: '3.9'
- tox_env: django32-py39
- - python: '3.9'
- tox_env: django40-py39
- - python: '3.9'
- tox_env: django41-py39
- - python: '3.9'
tox_env: django42-py39
- python: '3.10'
- tox_env: django22-py310
- - python: '3.10'
- tox_env: django32-py310
- - python: '3.10'
- tox_env: django40-py310
- - python: '3.10'
- tox_env: django41-py310
- - python: '3.10'
tox_env: django42-py310
- python: '3.10'
+ tox_env: django50-py310
+ - python: '3.10'
tox_env: django_main-py310
- python: '3.10'
tox_env: no_rest_framework
- python: '3.11'
tox_env: django_main-py311
- python: '3.11'
- tox_env: django42-py311
+ tox_env: django50-py311
- python: '3.11'
- tox_env: django41-py311
- - python: '3.11'
- tox_env: django40-py311
- - python: '3.11'
- tox_env: django32-py311
- - python: '3.11'
- tox_env: django22-py311
+ tox_env: django42-py311
- python: '3.11'
tox_env: no_rest_framework
name: ${{ matrix.tox_env }}
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 1
@@ -111,7 +73,7 @@
- run: coverage xml -i
- name: Upload coverage to Codecov
- uses: codecov/[email protected]
+ uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
name: codecov-py${{ matrix.python }}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/.github/workflows/release.yml
new/django-money-3.5.2/.github/workflows/release.yml
--- old/django-money-3.4.1/.github/workflows/release.yml 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/.github/workflows/release.yml 2024-05-07
23:30:47.000000000 +0200
@@ -9,11 +9,11 @@
name: Build and publish Python ðdistributions ð¦ to PyPI
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@master
- - name: Set up Python 3.9
- uses: actions/setup-python@v1
+ - uses: actions/checkout@v4
+ - name: Set up Python 3.10
+ uses: actions/setup-python@v5
with:
- python-version: 3.9
+ python-version: "3.10"
- name: Install tox
run: >-
python -m
@@ -24,6 +24,6 @@
run: >-
python -m tox -e build
- name: Publish distribution ð¦ to PyPI
- uses: pypa/gh-action-pypi-publish@master
+ uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/.pre-commit-config.yaml
new/django-money-3.5.2/.pre-commit-config.yaml
--- old/django-money-3.4.1/.pre-commit-config.yaml 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/.pre-commit-config.yaml 2024-05-07
23:30:47.000000000 +0200
@@ -2,7 +2,7 @@
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.2.0
+ rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-yaml
@@ -14,7 +14,7 @@
- --remove
- repo: https://github.com/asottile/pyupgrade
- rev: v2.32.0
+ rev: v3.15.2
hooks:
- id: pyupgrade
args:
@@ -31,7 +31,7 @@
- id: isort
- repo: https://github.com/pycqa/flake8
- rev: 3.9.2
+ rev: 7.0.0
hooks:
- id: flake8
exclude: ^docs
@@ -47,13 +47,13 @@
- --ignore-roles=github-issue,github-user
- repo: https://github.com/psf/black
- rev: 22.3.0
+ rev: 24.4.2
hooks:
- id: black
exclude: ^docs
- repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.2.0
+ rev: v1.10.0
hooks:
- id: mypy
additional_dependencies:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/Makefile
new/django-money-3.5.2/Makefile
--- old/django-money-3.4.1/Makefile 2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/Makefile 2024-05-07 23:30:47.000000000 +0200
@@ -28,7 +28,7 @@
rm -fr htmlcov/
test:
- python setup.py test --pytest-args="--cov=./djmoney tests"
+ pytest --cov=./djmoney tests
coverage:
coverage run --source djmoney setup.py test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/README.rst
new/django-money-3.5.2/README.rst
--- old/django-money-3.4.1/README.rst 2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/README.rst 2024-05-07 23:30:47.000000000 +0200
@@ -140,6 +140,37 @@
* Euros should be between 100 and 1000;
* US Dollars should be between 50 and 500;
+Constructing form data
+----------------------
+
+The default ``ModelForm`` class will use a form field
(``djmoney.forms.fields.MoneyField``) that is constructed of two separate
fields for amount and currency.
+
+If you need to feed data directly to such a form (for instance if you are
writing a test case), then you need to pass amount and currency like this:
+
+
+
+.. code:: python
+
+ # models.py
+ class Product(models.Model):
+ price = MoneyField(
+ max_digits=14,
+ decimal_places=2,
+ default_currency='EUR'
+ )
+
+ # forms.py
+ class ProductForm(ModelForm):
+ class Meta:
+ model = Product
+ fields = ["price"]
+
+ # tests.py
+
+ # construct the form in your test case
+ form = ProductForm({'price_0': 10, 'price_1': 'EUR'})
+
+
Adding a new Currency
---------------------
@@ -392,7 +423,7 @@
.. code:: python
- CELERYBEAT_SCHEDULE = {
+ CELERY_BEAT_SCHEDULE = {
'update_rates': {
'task': 'path.to.your.task',
'schedule': crontab(minute=0, hour=0),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/djmoney/__init__.py
new/django-money-3.5.2/djmoney/__init__.py
--- old/django-money-3.4.1/djmoney/__init__.py 2023-11-30 20:36:13.000000000
+0100
+++ new/django-money-3.5.2/djmoney/__init__.py 2024-05-07 23:30:47.000000000
+0200
@@ -1,4 +1,4 @@
-__version__ = "3.4.1"
+__version__ = "3.5.2"
try:
import django
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-money-3.4.1/djmoney/contrib/django_rest_framework/fields.py
new/django-money-3.5.2/djmoney/contrib/django_rest_framework/fields.py
--- old/django-money-3.4.1/djmoney/contrib/django_rest_framework/fields.py
2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/djmoney/contrib/django_rest_framework/fields.py
2024-05-07 23:30:47.000000000 +0200
@@ -65,8 +65,16 @@
return super().to_internal_value(data)
def get_value(self, data):
+ default_currency = None
+ parent_meta = getattr(self.parent, "Meta", None)
+
+ if parent_meta and hasattr(parent_meta, "model"):
+ model_meta = self.parent.Meta.model._meta
+ field = model_meta.get_field(self.source)
+ default_currency = field.default_currency
+
amount = super().get_value(data)
- currency = data.get(get_currency_field_name(self.field_name),
self.default_currency)
+ currency = data.get(get_currency_field_name(self.field_name),
self.default_currency or default_currency)
if currency and amount is not None and not isinstance(amount,
MONEY_CLASSES) and amount is not empty:
return _PrimitiveMoney(amount=amount, currency=currency)
return amount
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-money-3.4.1/djmoney/contrib/exchange/backends/openexchangerates.py
new/django-money-3.5.2/djmoney/contrib/exchange/backends/openexchangerates.py
---
old/django-money-3.4.1/djmoney/contrib/exchange/backends/openexchangerates.py
2023-11-30 20:36:13.000000000 +0100
+++
new/django-money-3.5.2/djmoney/contrib/exchange/backends/openexchangerates.py
2024-05-07 23:30:47.000000000 +0200
@@ -18,4 +18,4 @@
self.access_key = access_key
def get_params(self):
- return {"app_id": self.access_key}
+ return {"app_id": self.access_key, "base": settings.BASE_CURRENCY}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/djmoney/models/fields.py
new/django-money-3.5.2/djmoney/models/fields.py
--- old/django-money-3.4.1/djmoney/models/fields.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/djmoney/models/fields.py 2024-05-07
23:30:47.000000000 +0200
@@ -255,7 +255,11 @@
def contribute_to_class(self, cls, name):
cls._meta.has_money_field = True
- if not hasattr(self, "_currency_field") and not cls.__module__ ==
"__fake__":
+ # Note the discussion about whether or not the currency field should
be added in migrations:
+ # https://github.com/django-money/django-money/issues/725
+ # https://github.com/django-money/django-money/pull/726
+ # https://github.com/django-money/django-money/issues/731
+ if not hasattr(self, "_currency_field"):
self.add_currency_field(cls, name)
super().contribute_to_class(cls, name)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/djmoney/serializers.py
new/django-money-3.5.2/djmoney/serializers.py
--- old/django-money-3.4.1/djmoney/serializers.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/djmoney/serializers.py 2024-05-07
23:30:47.000000000 +0200
@@ -39,7 +39,7 @@
money_fields = {}
fields = {}
field_names = {field.name for field in Model._meta.get_fields()}
- for (field_name, field_value) in obj["fields"].items():
+ for field_name, field_value in obj["fields"].items():
if ignore and field_name not in field_names:
# skip fields no longer on model
continue
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/docs/changes.rst
new/django-money-3.5.2/docs/changes.rst
--- old/django-money-3.4.1/docs/changes.rst 2023-11-30 20:36:13.000000000
+0100
+++ new/django-money-3.5.2/docs/changes.rst 2024-05-07 23:30:47.000000000
+0200
@@ -1,22 +1,42 @@
Changelog
=========
-`Unreleased`_ (TBA)
--------------------
+`3.5.2`_ - 2024-05-07
+---------------------
**Fixed**
-- (add changelog entry)
+- django-rest-framework: Fix regression from 3.5 :github-issue:`762`
(:github-user:`dariusmazeika`)
-**Changed**
+`3.5.1`_ - 2024-05-05
+---------------------
-- (add changelog entry)
+**Fixed**
+
+- django-rest-framework: Fix regression from 3.5 :github-issue:`757`
(:github-user:`phillipuniverse`)
+
+
+`3.5`_ - 2024-05-04
+-------------------
+.. important::
+
+ If you generated ``MoneyField`` migrations in the previous series 3.4.x,
you may have to manually edit subsequent migrations. Please share your
successful approaches in :github-issue:`731`.
+
+
+**Fixed**
+
+- Revert 3.4 patch, meaning that auto-generated CurrencyField is once again
part of migrations :github-issue:`731` (:github-user:`benjaoming`)
+- django-rest-framework: MinMoneyValidator and MaxMoneyValidator fixed, may
require default_currency defined :github-issue:`722`
(:github-user:`hosamhamdy258` :github-user:`errietta` :github-user:`benjaoming`)
**Added**
-- (add changelog entry)
+- Django 5.0 support :github-issue:`753` (:github-user:`benjaoming`)
+
+**Removed**
+
+- Official support for Django 2.2, 3.2, 4.0, 4.1 :github-issue:`753`
(:github-user:`benjaoming`)
`3.4.1`_ - 2023-11-30
@@ -813,8 +833,11 @@
- Initial public release
-.. _Unreleased:
https:///github.com/django-money/django-money/compare/3.4.1...HEAD
+# .. _3.5: https:///github.com/django-money/django-money/compare/3.5...HEAD
+.. _3.5.2: https:///github.com/django-money/django-money/compare/3.5.2...3.5.1
+.. _3.5.1: https:///github.com/django-money/django-money/compare/3.5.1...3.5
+.. _3.5: https:///github.com/django-money/django-money/compare/3.5...3.4.1
.. _3.4.1: https:///github.com/django-money/django-money/compare/3.4...3.4.1
.. _3.4: https:///github.com/django-money/django-money/compare/3.3...3.4
.. _3.3: https:///github.com/django-money/django-money/compare/3.2...3.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/pytest.ini
new/django-money-3.5.2/pytest.ini
--- old/django-money-3.4.1/pytest.ini 2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/pytest.ini 2024-05-07 23:30:47.000000000 +0200
@@ -1,6 +1,8 @@
[pytest]
DJANGO_SETTINGS_MODULE=tests.settings
+django_find_project = false
filterwarnings =
error::DeprecationWarning
ignore:pkg_resources is deprecated as an API:DeprecationWarning
addopts = "--no-cov-on-fail"
+pythonpath = .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/setup.py
new/django-money-3.5.2/setup.py
--- old/django-money-3.4.1/setup.py 2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/setup.py 2024-05-07 23:30:47.000000000 +0200
@@ -1,36 +1,13 @@
import codecs
import os
import re
-import sys
from setuptools import find_packages, setup
-from setuptools.command.test import test as TestCommand
-
-
-class PyTest(TestCommand):
- user_options = [("pytest-args=", "a", "Arguments to pass into py.test")]
-
- def initialize_options(self):
- TestCommand.initialize_options(self)
- self.pytest_args = []
-
- def finalize_options(self):
- TestCommand.finalize_options(self)
- self.test_args = []
- self.test_suite = True
-
- def run_tests(self):
- import pytest
-
- errno = pytest.main(self.pytest_args)
- sys.exit(errno)
test_requirements = [
- # Quickfix for
https://docs.pytest.org/en/7.1.x/deprecations.html#using-pytest-warns-none
- "pytest>=3.1.0,<7.0",
+ "pytest>=8.2,<8.3",
"pytest-django",
- "pytest-pythonpath",
"pytest-cov",
"mixer",
"mypy",
@@ -94,5 +71,4 @@
],
tests_require=test_requirements,
extras_require=extras_requirements,
- cmdclass={"test": PyTest},
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-money-3.4.1/tests/contrib/exchange/test_model.py
new/django-money-3.5.2/tests/contrib/exchange/test_model.py
--- old/django-money-3.4.1/tests/contrib/exchange/test_model.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tests/contrib/exchange/test_model.py 2024-05-07
23:30:47.000000000 +0200
@@ -75,6 +75,7 @@
settings.INSTALLED_APPS.remove("djmoney.contrib.exchange")
with pytest.raises(ImproperlyConfigured):
convert_money(Money(1, "USD"), "EUR")
+ settings.INSTALLED_APPS.append("djmoney.contrib.exchange")
def test_without_installed_exchange(testdir):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-money-3.4.1/tests/contrib/test_django_rest_framework.py
new/django-money-3.5.2/tests/contrib/test_django_rest_framework.py
--- old/django-money-3.4.1/tests/contrib/test_django_rest_framework.py
2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tests/contrib/test_django_rest_framework.py
2024-05-07 23:30:47.000000000 +0200
@@ -1,6 +1,8 @@
from collections import Counter
from decimal import Decimal
+from django.test import override_settings
+
import pytest
from djmoney.money import Money
@@ -203,3 +205,84 @@
serializer = Serializer(data=data)
serializer.is_valid(raise_exception=True)
assert serializer.validated_data["money"] == expected
+
+
+# Test case contributed for
+# https://github.com/django-money/django-money/pull/722
+class TestMinValueSerializer:
+
+ @override_settings(DEFAULT_CURRENCY="EUR")
+ @pytest.mark.parametrize(
+ ("data", "is_valid"),
+ [
+ pytest.param({"money": Money(-1, "EUR")}, False,
id="is_invalid_money_value"),
+ pytest.param({"money": Money(1, "EUR")}, True,
id="is_valid_money_value"),
+ pytest.param({"money": "-1", "money_currency": "EUR"}, False,
id="is_invalid_dict_value"),
+ pytest.param({"money": "0.01", "money_currency": "EUR"}, True,
id="is_valid_dict_value"),
+ ],
+ )
+ def test_serializer_validator_field_without_default_currency(self, data,
is_valid):
+ from djmoney.contrib.django_rest_framework import MoneyField
+
+ class MinValueSerializer(serializers.Serializer):
+ money = MoneyField(decimal_places=2, max_digits=10, min_value=0)
+
+ class Meta:
+ model = ModelWithVanillaMoneyField
+
+ serializer = MinValueSerializer(data=data)
+ if is_valid:
+ assert serializer.is_valid()
+ else:
+ assert not serializer.is_valid()
+ assert serializer.errors["money"][0] == "Ensure this value is
greater than or equal to 0."
+
+ @pytest.mark.parametrize(
+ ("data", "is_valid"),
+ [
+ pytest.param({"second_money": Money(-1, "EUR")}, False,
id="is_invalid_money_value"),
+ pytest.param({"second_money": Money(1, "EUR")}, True,
id="is_valid_money_value"),
+ pytest.param({"second_money": "-1", "second_money_currency":
"EUR"}, False, id="is_invalid_dict_value"),
+ pytest.param({"second_money": "0.01", "second_money_currency":
"EUR"}, True, id="is_valid_dict_value"),
+ ],
+ )
+ def test_serializer_validator_field_with_default_currencey(self, data,
is_valid):
+ from djmoney.contrib.django_rest_framework import MoneyField
+
+ class MinValueSerializer(serializers.Serializer):
+ second_money = MoneyField(decimal_places=2, max_digits=10,
min_value=0)
+
+ class Meta:
+ model = ModelWithVanillaMoneyField
+
+ serializer = MinValueSerializer(data=data)
+ if is_valid:
+ assert serializer.is_valid()
+ else:
+ assert not serializer.is_valid()
+ assert serializer.errors["second_money"][0] == "Ensure this value
is greater than or equal to 0."
+
+ def test_no_model_serializer(self):
+ from djmoney.contrib.django_rest_framework import MoneyField
+
+ class NormalSerializer(serializers.Serializer):
+ the_money = MoneyField(decimal_places=2, max_digits=10,
min_value=0)
+
+ class Meta:
+ fields = ("the_money",)
+
+ serializer = NormalSerializer(data={"the_money": "0.01",
"the_money_currency": "EUR"})
+ assert serializer.is_valid()
+
+ def test_model_serializer_with_field_source(self):
+ class ModelSerializer(serializers.ModelSerializer):
+ renamed_money_field = djmoney_fields.MoneyField(
+ source="money", max_digits=10, decimal_places=2, min_value=0
+ )
+
+ class Meta:
+ model = ModelWithVanillaMoneyField
+ fields = ("renamed_money_field",)
+
+ serializer = ModelSerializer(data={"renamed_money_field": "0.01",
"renamed_money_field_currency": "EUR"})
+ assert serializer.is_valid()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/tests/migrations/helpers.py
new/django-money-3.5.2/tests/migrations/helpers.py
--- old/django-money-3.4.1/tests/migrations/helpers.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tests/migrations/helpers.py 2024-05-07
23:30:47.000000000 +0200
@@ -1,6 +1,7 @@
"""
This module contains various helpers for migrations testing.
"""
+
import os
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-money-3.4.1/tests/migrations/test_migrations.py
new/django-money-3.5.2/tests/migrations/test_migrations.py
--- old/django-money-3.4.1/tests/migrations/test_migrations.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tests/migrations/test_migrations.py 2024-05-07
23:30:47.000000000 +0200
@@ -125,7 +125,12 @@
def test_create_initial(self):
migration = self.make_default_migration()
- migration.stdout.fnmatch_lines(["*Migrations for 'money_app':*",
"*0001_test.py*", "*- Create model Model*"])
+ print(migration.stdout)
+ # Django 5 output replaced "-" with "+"
+ # Migrations for 'money_app':
+ # money_app/migrations/0001_test.py
+ # + Create model Model
+ migration.stdout.fnmatch_lines(["*Migrations for 'money_app':*",
"*0001_test.py*", "*Create model Model*"])
operations = get_operations("0001")
assert len(operations) == 1
@@ -147,8 +152,8 @@
[
"*Migrations for 'money_app':*",
"*0002_test.py*",
- "*- Add field field to model*",
- "*- Add field field_currency to model*",
+ "*Add field field to model*",
+ "*Add field field_currency to model*",
]
)
@@ -164,7 +169,7 @@
self.make_default_migration()
migration = self.make_migration(field="MoneyField(max_digits=15,
decimal_places=2, null=True)")
migration.stdout.fnmatch_lines(
- ["*Migrations for 'money_app':*", "*0002_test.py*", "*- Alter
field field on model*"]
+ ["*Migrations for 'money_app':*", "*0002_test.py*", "*Alter field
field on model*"]
)
operations = get_operations("0002")
@@ -181,8 +186,8 @@
[
"*Migrations for 'money_app':*",
"*0002_test.py*",
- "*- Remove field field from model*",
- "*- Remove field field_currency from model*",
+ "*Remove field field from model*",
+ "*Remove field field_currency from model*",
]
)
@@ -203,8 +208,8 @@
[
"*Migrations for 'money_app':*",
"*0002_test.py*",
- "*- Rename field field on model to new_field*",
- "*- Rename field field_currency on model to
new_field_currency*",
+ "*Rename field field on model to new_field*",
+ "*Rename field field_currency on model to new_field_currency*",
]
)
self.assert_migrate(["*Applying money_app.0002_test... OK*"])
@@ -222,7 +227,7 @@
self.make_default_migration(field="models.DecimalField(max_digits=10,
decimal_places=2, null=True)")
migration = self.make_migration(field="MoneyField(max_digits=10,
decimal_places=2, null=True)")
migration.stdout.fnmatch_lines(
- ["*Migrations for 'money_app':*", "*0002_test.py*", "*- Add field
field_currency to model*"]
+ ["*Migrations for 'money_app':*", "*0002_test.py*", "*Add field
field_currency to model*"]
)
self.assert_migrate()
@@ -230,6 +235,6 @@
self.make_default_migration()
migration =
self.make_migration(field="models.DecimalField(max_digits=10, decimal_places=2,
null=True)")
migration.stdout.fnmatch_lines(
- ["*Migrations for 'money_app':*", "*0002_test.py*", "*- Remove
field field_currency from model*"]
+ ["*Migrations for 'money_app':*", "*0002_test.py*", "*Remove field
field_currency from model*"]
)
self.assert_migrate()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/tests/test_form.py
new/django-money-3.5.2/tests/test_form.py
--- old/django-money-3.4.1/tests/test_form.py 2023-11-30 20:36:13.000000000
+0100
+++ new/django-money-3.5.2/tests/test_form.py 2024-05-07 23:30:47.000000000
+0200
@@ -3,6 +3,8 @@
@author: jake
"""
+
+import warnings
from decimal import Decimal
import pytest
@@ -122,9 +124,9 @@
"""
The library's code shouldn't generate any warnings itself. See #262.
"""
- with pytest.warns(None) as warning:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
MoneyField(max_digits=10, decimal_places=2, currency_choices=(("USD",
"USD"),)).formfield()
- assert not warning
class TestValidation:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/tests/test_models.py
new/django-money-3.5.2/tests/test_models.py
--- old/django-money-3.4.1/tests/test_models.py 2023-11-30 20:36:13.000000000
+0100
+++ new/django-money-3.5.2/tests/test_models.py 2024-05-07 23:30:47.000000000
+0200
@@ -3,6 +3,7 @@
@author: jake
"""
+
import datetime
from copy import copy
from decimal import Decimal, InvalidOperation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/tests/testapp/forms.py
new/django-money-3.5.2/tests/testapp/forms.py
--- old/django-money-3.4.1/tests/testapp/forms.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tests/testapp/forms.py 2024-05-07
23:30:47.000000000 +0200
@@ -3,6 +3,7 @@
@author: jake
"""
+
from django import forms
from djmoney.forms import MoneyField
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/tests/testapp/models.py
new/django-money-3.5.2/tests/testapp/models.py
--- old/django-money-3.4.1/tests/testapp/models.py 2023-11-30
20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tests/testapp/models.py 2024-05-07
23:30:47.000000000 +0200
@@ -3,6 +3,7 @@
@author: jake
"""
+
from decimal import Decimal
from django.conf import settings
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-money-3.4.1/tox.ini
new/django-money-3.5.2/tox.ini
--- old/django-money-3.4.1/tox.ini 2023-11-30 20:36:13.000000000 +0100
+++ new/django-money-3.5.2/tox.ini 2024-05-07 23:30:47.000000000 +0200
@@ -1,11 +1,8 @@
[tox]
envlist =
- django_main-py{311,310}
+ django_main-py{312,311,310}
+ django50-py{312, 311,310}
django42-py{311,310,39,38}
- django41-py{311,310,39,38,py3}
- django40-py{311,310,39,38,py3}
- django32-py{311,310,39,38,37,py3}
- django22-py{311,310,39,38,37,py3}
lint
docs
skipsdist = true
@@ -17,20 +14,14 @@
[testenv]
deps =
.[test,exchange]
- django22: {[django]22}
- django32: {[django]32}
- django40: {[django]40}
- django41: {[django]41}
django42: {[django]42}
+ django50: {[django]50}
django_main: {[django]main}
#
https://github.com/django-money/django-money/pull/716#issuecomment-1592594627
pypy3: asgiref<=3.6
commands = py.test --ds=tests.settings_reversion --cov=./djmoney {posargs}
usedevelop = false
-[testenv:django_main-py{39,38,py3}]
-commands = py.test --ds=tests.settings --cov=./djmoney {posargs}
-
[testenv:lint]
deps =
pre-commit
@@ -38,26 +29,14 @@
pre-commit run --all-files
[django]
-22 =
- Django>=2.2,<2.3
- django-reversion>=2.0.8
- djangorestframework>=3.7.3
-32 =
- Django>=3.2,<3.3
- django-reversion>=3.0.8
- djangorestframework>=3.12.0
-40 =
- Django>=4.0,<4.1
- django-reversion>=4.0.0
- djangorestframework>=3.13.0
-41 =
- Django>=4.1a1,<4.2
- django-reversion>=4.0.0
- djangorestframework>=3.13.0
42 =
Django>=4.2a1,<4.3
django-reversion>=4.0.0
djangorestframework>=3.13.0
+50 =
+ Django>=5.0,<5.1
+ django-reversion>=4.0.0
+ djangorestframework>=3.13.0
main =
https://github.com/django/django/tarball/main
django-reversion>=4.0.0
@@ -66,7 +45,7 @@
[testenv:no_rest_framework]
deps =
.[test,exchange]
- Django>=2.2,<4.2
+ Django>=4.2,<4.3
django-reversion>=4.0.0
[testenv:docs]