Skip to content

Commit

Permalink
Drop obsolete model_bakery.timezone.now
Browse files Browse the repository at this point in the history
And use `django.utils.timezone.now` instead.
Refs #35.
  • Loading branch information
Rust Saiargaliev committed Feb 10, 2021
1 parent 73bdb9b commit 2ec3eac
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Modify `setup.py` to not import the whole module for package data, but get it from `__about__.py`

### Removed
- `model_bakery.timezone.now` fallback (use `django.utils.timezone.now` instead)


## [1.2.1](https://pypi.org/project/model-bakery/1.2.1/)
Expand Down
3 changes: 1 addition & 2 deletions model_bakery/random_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

from django.core.files.base import ContentFile
from django.db.models import Field, Model

from .timezone import now
from django.utils.timezone import now

MAX_LENGTH = 300
# Using sys.maxint here breaks a bunch of tests when running against a
Expand Down
9 changes: 2 additions & 7 deletions model_bakery/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@

from datetime import datetime

try:
from django.conf import settings
from django.utils.timezone import now, utc
except ImportError:

def now():
return datetime.now()
from django.conf import settings
from django.utils.timezone import utc


def smart_datetime(*args) -> datetime:
Expand Down
3 changes: 2 additions & 1 deletion tests/generic/baker_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from datetime import timedelta
from decimal import Decimal

from django.utils.timezone import now

from model_bakery.recipe import Recipe, foreign_key, related, seq
from model_bakery.timezone import now
from tests.generic.models import (
TEST_TIME,
Dog,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from unittest.mock import patch

import pytest
from django.utils.timezone import now

from model_bakery import baker
from model_bakery.exceptions import InvalidQuantityException, RecipeIteratorEmpty
from model_bakery.recipe import Recipe, RecipeForeignKey, foreign_key
from model_bakery.timezone import now, tz_aware
from model_bakery.timezone import tz_aware
from tests.generic.baker_recipes import SmallDogRecipe, pug
from tests.generic.models import (
TEST_TIME,
Expand Down

0 comments on commit 2ec3eac

Please sign in to comment.