Maarten ter Huurne
23f1811b9d
Annotate return type of test methods
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
218843d754
Add minimal annotations to unit tests
...
These annotations are sufficient to pass mypy inspection if mypy is
configured to allow unannotated functions.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
aeeb69a9dd
Enable postponed evaluation of annotations for all test modules
...
This allows using the latest annotation syntax supported by the type
checker regardless of the runtime Python version.
2024-06-13 12:02:05 +02:00
Jelmer
e35c72427b
Merge pull request #624 from ProtixIT/DescriptorWrapper-no-catch
...
Remove catching of `AttributeError` in `DescriptorWrapper`
2024-06-13 10:58:11 +02:00
Jelmer
4275f84e7c
Merge pull request #614 from ProtixIT/splitfield-notnone
...
Remove support for assigning `None` to a `SplitField`
2024-06-13 09:25:40 +02:00
Maarten ter Huurne
a6b0a2aff7
Fix and re-enable AbstractModelTrackerTests
...
There used to be a [bug in Django](https://code.djangoproject.com/ticket/30427 )
that caused these tests to fail, according to the discussion of #370 .
That bug was fixed in Django 4.0.
However, because the test model was using a `FieldTracker`
rather than a `ModelTracker`, all model-specific test cases
in `ModelTrackerTests` continued to fail.
2024-06-12 16:54:14 +02:00
Maarten ter Huurne
c2d6cb5021
Remove support for assigning None to a SplitField
...
This behavior wasn't documented and didn't fully work: it breaks
as soon as you try to save a model with a `None` value.
2024-04-16 08:05:13 +02:00
Maarten ter Huurne
512d0f1890
Avoid deprecated SoftDeletableModel.objects manager in tests
...
Use the `available_objects` manager instead.
2024-04-16 04:02:33 +02:00
Maarten ter Huurne
800961626a
Move CustomSoftDeleteQuerySet to tests.models
...
The `CustomSoftDeleteQuerySet` class was the only code left in
the `test.managers` module, while it is not in fact a `Manager`.
2024-04-16 04:02:33 +02:00
Maarten ter Huurne
68a4c14c74
Auto-generate manager implementation for CustomSoftDelete
...
Besides requiring less code, this also allows the django-stubs
mypy plugin to automatically generate a type-annotated version
of the manager.
Unfortunately, the plugin does not put a `ClassVar` annotation
on `objects`, which is why we need the suppression.
2024-04-16 04:02:12 +02:00
Maarten ter Huurne
2f58a1160d
Add minimal type annotations to make mypy pass
...
Avoid using `Self` as a type argument: for some reason this fails
when mypy has an empty cache, but passes when the cache has been
filled. Maybe it's a weird interaction between the mypy core and
the django-stubs plugin?
2024-04-05 17:16:06 +02:00
Maarten ter Huurne
441e3adee5
Make default port a string
...
Django can handle both strings and integers, but typeshed expects the
default value to match the mapping's value type.
2024-04-05 17:15:16 +02:00
Guilherme Martins Crocetti
4c9d6eee13
feat(monitor): Change default to None when the field is marked as nullable and no default is provided ( #599 )
2024-04-04 10:26:17 +02:00
Maarten ter Huurne
d320924383
Forward additional arguments to contribute_to_class() to Django ( #605 )
...
* Pass additional arguments to superclass `contribute_to_class()`
In Django 3.2 there is an additional argument `private_only` and more
could be added in future versions.
2024-04-03 08:53:52 +02:00
Maarten ter Huurne
d8c43eab46
Add tracker to method signatures in FieldTrackerTestCase
2024-03-26 13:56:39 +01:00
Jelmer
8bef73cd99
Merge pull request #563 from foarsitter/docker_postgresql
...
Postgresql docker container for local development
2024-03-25 19:06:28 +01:00
Jelmer
87a9466afa
Merge pull request #598 from ProtixIT/remove-obsolete-test-models
...
Remove obsolete test models
2024-03-22 21:28:03 +01:00
Jelmer
fc49c636a9
Merge pull request #597 from ProtixIT/remove-signal-test-helper
...
Remove obsolete `tests.signals` module
2024-03-22 21:27:13 +01:00
Maarten ter Huurne
9df3df99cf
Remove obsolete NoRendered test model
...
The code under test was removed in fda2d39e , but this model remained.
2024-03-22 18:50:05 +01:00
Maarten ter Huurne
6c39b58cb4
Remove FeaturedManager and related obsolete test model code
...
The code under test was removed in 6ae66e01 , but some of the test code
remained.
2024-03-22 18:43:45 +01:00
Jelmer
6e722b51b0
Merge pull request #596 from ProtixIT/status-test-model-naming
...
Resolve name clash among test models
2024-03-22 18:00:40 +01:00
Jelmer
aaf93c9d40
Merge pull request #595 from ProtixIT/skip-reason
...
Pass reason to `@skip` decorator
2024-03-22 18:00:03 +01:00
Jelmer
281c52013e
Merge pull request #594 from ProtixIT/joinmanager
...
Remove redundant definition of `JoinManager` from tests
2024-03-22 17:58:14 +01:00
Maarten ter Huurne
6f16488ef3
Remove tests.signals module
...
This module was support code for the `SaveSignalHandlingModel` tests.
That class got introduced in 5d6f8f4e and removed in 11f3a53b , but
the support code remained.
2024-03-22 17:53:59 +01:00
Maarten ter Huurne
ed4f04f282
Resolve name clash among test models
...
There were two classes named `StatusCustomManager`: the first is an
actual manager, the second a status model that uses a custom manager.
The latter is renamed to `CustomManagerStatusModel` in this commit.
2024-03-22 17:32:51 +01:00
Maarten ter Huurne
ab8a8ae53a
Pass reason to @skip decorator
...
The decorator works without an argument as well, but that is an
undocumented feature of `unittest.skip()` that is not understood
by mypy and pytest.
In the case of pytest, it ignored the decorated class during test
collection, instead of collecting it and marking it as skipped.
2024-03-22 16:58:09 +01:00
Maarten ter Huurne
b7677161cb
Remove redundant definition of JoinManager from tests
...
The `JoinManager` class already exists in `model_utils.managers`,
with the exact same definition.
2024-03-22 16:29:37 +01:00
Jelmer Draaijer
1979d4796f
USE_TZ = True
2024-03-22 16:13:29 +01:00
Jelmer
26336b41f6
Merge pull request #510 from adamchainz/time_machine
...
Switch from freezegun to time-machine.
2024-03-22 15:46:19 +01:00
Guilherme Martins Crocetti
22015b8e69
chore(monitor-field): Add deprecation warning when the field is null and no default is provided. The new behavior will be introduced in a next major release
2024-03-21 20:05:14 -03:00
Jelmer Draaijer
8677eef1ca
Rename database environment variables to align with the docker postgres image
2024-03-21 16:00:35 +01:00
Jelmer
6e7158bfa0
Merge pull request #516 from jayvdb/allow-sqlite-testing
...
Allow running tests using sqlite
2024-03-21 15:41:12 +01:00
Maarten ter Huurne
a1530ad838
Update where ConnectionDoesNotExist is imported from
...
It was moved to a different package in Django 3.2.
2024-03-21 14:18:19 +01:00
Joseph Riddle
55cd816939
Merge branch 'master' into fix-prefetch-related
2023-11-27 12:55:53 -08:00
Adam Johnson
11f3a53b0f
Remove SaveSignalHandlingModel
2023-10-26 16:56:30 +01:00
Serhii Tereshchenko
0ec4ac5e38
fix: Use proper column name instead of attname ( #573 )
...
fix: Use proper column name instead of attname
2023-06-16 15:34:47 +02:00
joeriddles
103c942ca5
Fix docstring for prefetch_related test class
2023-01-26 14:25:43 -08:00
joeriddles
604c6f0b62
Remove unnecessary model and simplify tests for prefetch_related
2023-01-26 14:25:09 -08:00
joeriddles
a0624f1492
For error on prefetch_related for tracked field
2023-01-26 13:17:49 -08:00
Hasan Ramezani
0b5475e3d5
Add pyupgrade to pre-commit configurations
2022-08-17 23:08:31 +02:00
Hasan Ramezani
b354d90c20
Drop support for Django < 3.2
2022-08-17 23:08:29 +02:00
Tim Gates
2dab8afded
docs: Fix a few typos
...
There are small typos in:
- docs/managers.rst
- model_utils/managers.py
- tests/test_models/test_timestamped_model.py
Fixes:
- Should read `subclasses` rather than `subclasess`.
- Should read `queryset` rather than `querset`.
- Should read `permissible` rather than `permissable`.
- Should read `modified` rather than `modifed`.
- Should read `heterogeneous` rather than `heterogenous`.
Signed-off-by: Tim Gates <tim.gates@iress.com>
2022-08-17 22:37:49 +02:00
Adam Johnson
262ac384ac
explicit timezones
2022-04-04 12:04:38 +01:00
Adam Johnson
8edd7c00fc
Switch from freezegun to time-machine.
...
It’s [more accurate](https://adamj.eu/tech/2020/06/03/introducing-time-machine/ ) and [faster](https://adamj.eu/tech/2021/02/19/freezegun-versus-time-machine/ ).
2022-04-04 11:53:18 +01:00
John Vandenberg
70963149d4
tests.settings: Update backend path
2021-12-26 13:49:49 +08:00
John Vandenberg
e6833a2d52
Allow running tests using sqlite
2021-12-26 12:31:12 +08:00
Hasan Ramezani
e418711f32
Add USE_TZ setting.
2021-12-08 12:33:23 +01:00
Ghassan Maslamani
b65a2ee41d
set deafult DB_host as localhost
2021-10-10 23:27:56 +06:00
Matthieu Rigal
6d4112e8ce
Fix performance regression: avoid pickling the whole instance when deepcopying fields on Django 3.1+ ( #500 )
...
* test: Add failing test for #gh-498
* fix: Fix performance regression on FileTracker for FileField on Django 3.1+
2021-10-09 21:30:12 +06:00
Sergey Tikhonov
79a7793dc5
#491 Context manager for resetting fields ( #494 )
...
* Add tracker context manager and decorator
* Handle auto-field warning in tests
* Use tracker context in monkey-patched methods
* Test delaying set_saved_fields call with context manager
* Docs for tracker context
* Describe FieldsContext context manager in changes
* Fix unused import
* #494 add breaking changes note on 4.1.1 release for #404
* #494 fix typo
* #494 add docstring for FieldsContext
* #494 move breaking changes from 4.1.1 to 4.1.0
* #494 fix typo and add some more docstrings
2021-10-08 15:09:20 +06:00