diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c075e28a..cfc7f74a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,15 @@ repos: + - repo: https://github.com/asottile/pyupgrade + rev: v1.26.2 + hooks: + - id: pyupgrade + args: ["--py3-plus"] + - repo: https://github.com/psf/black rev: 19.10b0 hooks: - id: black + args: ["--target-version", "py35"] - repo: https://gitlab.com/pycqa/flake8 rev: 3.7.9 @@ -29,4 +36,5 @@ repos: rev: v2.5.0 hooks: - id: check-merge-conflict + - id: check-toml - id: check-yaml diff --git a/.travis.yml b/.travis.yml index 046a29b7..f36fd538 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,12 @@ language: python cache: pip python: - - 2.7 + - pypy3 - 3.5 - 3.6 - 3.7 - 3.8 - 3.9-dev - - pypy - - pypy3 install: - pip install -U pip diff --git a/README.md b/README.md index 69ce239d..4201fe1e 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ [![MIT License](https://img.shields.io/github/license/jmoiron/humanize.svg)](LICENSE) This modest package contains various common humanization utilities, like turning -a number into a fuzzy human readable duration ('3 minutes ago') or into a human -readable size or throughput. It works with Python 2.7 and 3.5+ and is localized -to: +a number into a fuzzy human readable duration ("3 minutes ago") or into a human +readable size or throughput. It is localized to: +* Brazilian Portuguese * Dutch * Finnish * French @@ -22,7 +22,6 @@ to: * Japanese * Korean * Persian -* Portuguese Brazilian * Russian * Simplified Chinese * Slovak @@ -50,26 +49,28 @@ Integer humanization: Date & time humanization: ```pycon ->>> import datetime ->>> humanize.naturalday(datetime.datetime.now()) +>>> import humanize +>>> import datetime as dt +>>> humanize.naturalday(dt.datetime.now()) 'today' ->>> humanize.naturaldelta(datetime.timedelta(seconds=1001)) +>>> humanize.naturaldelta(dt.timedelta(seconds=1001)) '16 minutes' ->>> humanize.naturalday(datetime.datetime.now() - datetime.timedelta(days=1)) +>>> humanize.naturalday(dt.datetime.now() - dt.timedelta(days=1)) 'yesterday' ->>> humanize.naturalday(datetime.date(2007, 6, 5)) +>>> humanize.naturalday(dt.date(2007, 6, 5)) 'Jun 05' ->>> humanize.naturaldate(datetime.date(2007, 6, 5)) +>>> humanize.naturaldate(dt.date(2007, 6, 5)) 'Jun 05 2007' ->>> humanize.naturaltime(datetime.datetime.now() - datetime.timedelta(seconds=1)) +>>> humanize.naturaltime(dt.datetime.now() - dt.timedelta(seconds=1)) 'a second ago' ->>> humanize.naturaltime(datetime.datetime.now() - datetime.timedelta(seconds=3600)) +>>> humanize.naturaltime(dt.datetime.now() - dt.timedelta(seconds=3600)) 'an hour ago' ``` File size humanization: ```pycon +>>> import humanize >>> humanize.naturalsize(1000000) '1.0 MB' >>> humanize.naturalsize(1000000, binary=True) @@ -81,6 +82,7 @@ File size humanization: Human readable floating point numbers: ```pycon +>>> import humanize >>> humanize.fractional(1/3) '1/3' >>> humanize.fractional(1.5) @@ -98,13 +100,15 @@ Human readable floating point numbers: How to change locale at runtime: ```pycon ->>> print(humanize.naturaltime(datetime.timedelta(seconds=3))) +>>> import humanize +>>> import datetime as dt +>>> humanize.naturaltime(dt.timedelta(seconds=3)) 3 seconds ago ->>> _t = humanize.i18n.activate('ru_RU') ->>> print(humanize.naturaltime(datetime.timedelta(seconds=3))) +>>> _t = humanize.i18n.activate("ru_RU") +>>> humanize.naturaltime(dt.timedelta(seconds=3)) 3 секунды назад >>> humanize.i18n.deactivate() ->>> print(humanize.naturaltime(datetime.timedelta(seconds=3))) +>>> humanize.naturaltime(dt.timedelta(seconds=3)) 3 seconds ago ``` @@ -112,6 +116,7 @@ You can pass additional parameter `path` to `activate` to specify a path to sear locales in. ```pycon +>>> import humanize >>> humanize.i18n.activate("pt_BR") IOError: [Errno 2] No translation file found for domain: 'humanize' >>> humanize.i18n.activate("pt_BR", path="path/to/my/portuguese/translation/") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..dd2a02f1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +target_version = ["py35"] diff --git a/setup.cfg b/setup.cfg index fcb71efe..e7f6993a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[bdist_wheel] -universal = 1 - [flake8] max_line_length = 88 diff --git a/setup.py b/setup.py index 0d9e951c..af7eb8cf 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ -import io - from setuptools import find_packages, setup -with io.open("README.md", encoding="UTF-8") as f: +with open("README.md", encoding="UTF-8") as f: long_description = f.read() @@ -29,11 +27,8 @@ def local_scheme(version): zip_safe=False, use_scm_version={"local_scheme": local_scheme}, setup_requires=["setuptools_scm"], - extras_require={ - "tests": ["freezegun", "pytest", "pytest-cov"], - "tests:python_version < '3.4'": ["mock"], - }, - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", + extras_require={"tests": ["freezegun", "pytest", "pytest-cov"]}, + python_requires=">=3.5", # Get strings from https://pypi.org/pypi?%3Aaction=list_classifiers classifiers=[ "Development Status :: 5 - Production/Stable", @@ -41,13 +36,12 @@ def local_scheme(version): "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Text Processing", diff --git a/src/humanize/compat.py b/src/humanize/compat.py deleted file mode 100644 index ee79683d..00000000 --- a/src/humanize/compat.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys - -if sys.version_info < (3,): - string_types = (basestring,) # noqa: F821 -else: - string_types = (str,) diff --git a/src/humanize/filesize.py b/src/humanize/filesize.py index 8c1f646d..754a9f39 100644 --- a/src/humanize/filesize.py +++ b/src/humanize/filesize.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Bits & Bytes related humanization.""" diff --git a/src/humanize/i18n.py b/src/humanize/i18n.py index 6c4b2a29..de0741ec 100644 --- a/src/humanize/i18n.py +++ b/src/humanize/i18n.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import gettext as gettext_module import os.path from threading import local @@ -20,7 +19,8 @@ def get_translation(): def activate(locale, path=None): """Set 'locale' as current locale. Search for locale in directory 'path' - @param locale: language name, eg 'en_GB'""" + @param locale: language name, eg 'en_GB' + @param path: path to search for locales""" if path is None: path = _DEFAULT_LOCALE_PATH if locale not in _TRANSLATIONS: @@ -42,11 +42,16 @@ def pgettext(msgctxt, message): """'Particular gettext' function. It works with 'msgctxt' .po modifiers and allow duplicate keys with different translations. - Python 2 don't have support for this GNU gettext function, so we + This GNU gettext function was added in Python 3.8, so for older versions we reimplement it. It works by joining msgctx and msgid by '4' byte.""" - key = msgctxt + "\x04" + message - translation = get_translation().gettext(key) - return message if translation == key else translation + try: + # Python 3.8+ + return get_translation().pgettext(msgctxt, message) + except AttributeError: + # Python 3.7 and older + key = msgctxt + "\x04" + message + translation = get_translation().gettext(key) + return message if translation == key else translation def ngettext(message, plural, num): diff --git a/src/humanize/number.py b/src/humanize/number.py index 0177b056..cb5632a6 100644 --- a/src/humanize/number.py +++ b/src/humanize/number.py @@ -1,12 +1,10 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Humanizing functions for numbers.""" import re from fractions import Fraction -from . import compat from .i18n import gettext as _ from .i18n import gettext_noop as N_ from .i18n import pgettext as P_ @@ -43,7 +41,7 @@ def intcomma(value): some compatibility with Django's intcomma, this function also accepts floats.""" try: - if isinstance(value, compat.string_types): + if isinstance(value, str): float(value.replace(",", "")) else: float(value) @@ -138,15 +136,15 @@ def fractional(value): number = float(value) except (TypeError, ValueError): return value - wholeNumber = int(number) - frac = Fraction(number - wholeNumber).limit_denominator(1000) + whole_number = int(number) + frac = Fraction(number - whole_number).limit_denominator(1000) numerator = frac._numerator denominator = frac._denominator - if wholeNumber and not numerator and denominator == 1: + if whole_number and not numerator and denominator == 1: # this means that an integer was passed in # (or variants of that integer like 1.0000) - return "%.0f" % wholeNumber - elif not wholeNumber: - return "%.0f/%.0f" % (numerator, denominator) + return "%.0f" % whole_number + elif not whole_number: + return "{:.0f}/{:.0f}".format(numerator, denominator) else: - return "%.0f %.0f/%.0f" % (wholeNumber, numerator, denominator) + return "{:.0f} {:.0f}/{:.0f}".format(whole_number, numerator, denominator) diff --git a/src/humanize/time.py b/src/humanize/time.py index f104a18e..5e90610a 100644 --- a/src/humanize/time.py +++ b/src/humanize/time.py @@ -1,10 +1,9 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Time humanizing functions. These are largely borrowed from Django's ``contrib.humanize``.""" -from datetime import date, datetime, timedelta +import datetime as dt from .i18n import gettext as _ from .i18n import ngettext @@ -13,7 +12,7 @@ def _now(): - return datetime.now() + return dt.datetime.now() def abs_timedelta(delta): @@ -29,19 +28,19 @@ def date_and_delta(value): """Turn a value into a date and a timedelta which represents how long ago it was. If that's not possible, return (None, value).""" now = _now() - if isinstance(value, datetime): + if isinstance(value, dt.datetime): date = value delta = now - value - elif isinstance(value, timedelta): + elif isinstance(value, dt.timedelta): date = now - value delta = value else: try: value = int(value) - delta = timedelta(seconds=value) + delta = dt.timedelta(seconds=value) date = now - delta except (ValueError, TypeError): - return (None, value) + return None, value return date, abs_timedelta(delta) @@ -122,7 +121,7 @@ def naturaltime(value, future=False, months=True): if date is None: return value # determine tense by value only if datetime/timedelta were passed - if isinstance(value, (datetime, timedelta)): + if isinstance(value, (dt.datetime, dt.timedelta)): future = date > now ago = _("%s from now") if future else _("%s ago") @@ -139,14 +138,14 @@ def naturalday(value, format="%b %d"): present day returns representing string. Otherwise, returns a string formatted according to ``format``.""" try: - value = date(value.year, value.month, value.day) + value = dt.date(value.year, value.month, value.day) except AttributeError: # Passed value wasn't date-ish return value except (OverflowError, ValueError): # Date arguments out of range return value - delta = value - date.today() + delta = value - dt.date.today() if delta.days == 0: return _("today") elif delta.days == 1: @@ -160,14 +159,14 @@ def naturaldate(value): """Like naturalday, but will append a year for dates that are a year ago or more.""" try: - value = date(value.year, value.month, value.day) + value = dt.date(value.year, value.month, value.day) except AttributeError: # Passed value wasn't date-ish return value except (OverflowError, ValueError): # Date arguments out of range return value - delta = abs_timedelta(value - date.today()) + delta = abs_timedelta(value - dt.date.today()) if delta.days >= 365: return naturalday(value, "%b %d %Y") return naturalday(value) diff --git a/tests/base.py b/tests/base.py index 74b46403..80a7f70f 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Tests base classes.""" diff --git a/tests/test_filesize.py b/tests/test_filesize.py index e2ed7189..74a05aea 100644 --- a/tests/test_filesize.py +++ b/tests/test_filesize.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Tests for filesize humanizing.""" diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 4f6795bf..fe95d278 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import datetime as dt import humanize @@ -8,9 +7,13 @@ def test_i18n(): three_seconds = dt.timedelta(seconds=3) assert humanize.naturaltime(three_seconds) == "3 seconds ago" + assert humanize.ordinal(5) == "5th" - humanize.i18n.activate("ru_RU") - assert humanize.naturaltime(three_seconds) == "3 секунды назад" - - humanize.i18n.deactivate() - assert humanize.naturaltime(three_seconds) == "3 seconds ago" + try: + humanize.i18n.activate("ru_RU") + assert humanize.naturaltime(three_seconds) == "3 секунды назад" + assert humanize.ordinal(5) == "5ый" + finally: + humanize.i18n.deactivate() + assert humanize.naturaltime(three_seconds) == "3 seconds ago" + assert humanize.ordinal(5) == "5th" diff --git a/tests/test_number.py b/tests/test_number.py index 9539891d..66db1469 100644 --- a/tests/test_number.py +++ b/tests/test_number.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Number tests.""" diff --git a/tests/test_time.py b/tests/test_time.py index 14e603cf..0c0e3eaf 100644 --- a/tests/test_time.py +++ b/tests/test_time.py @@ -1,46 +1,41 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Tests for time humanizing.""" -try: - from unittest.mock import patch -except (ImportError, AttributeError): - from mock import patch - -from datetime import date, datetime, timedelta +import datetime as dt +from unittest.mock import patch from freezegun import freeze_time from humanize import time from .base import HumanizeTestCase -ONE_DAY = timedelta(days=1) +ONE_DAY = dt.timedelta(days=1) -class fakedate(object): +class FakeDate: def __init__(self, year, month, day): self.year, self.month, self.day = year, month, day -VALUE_ERROR_TEST = fakedate(290149024, 2, 2) -OVERFLOW_ERROR_TEST = fakedate(120390192341, 2, 2) +VALUE_ERROR_TEST = FakeDate(290149024, 2, 2) +OVERFLOW_ERROR_TEST = FakeDate(120390192341, 2, 2) class TimeUtilitiesTestCase(HumanizeTestCase): """These are not considered "public" interfaces, but require tests anyway.""" def test_date_and_delta(self): - now = datetime.now() - td = timedelta + now = dt.datetime.now() + td = dt.timedelta int_tests = (3, 29, 86399, 86400, 86401 * 30) date_tests = [now - td(seconds=x) for x in int_tests] td_tests = [td(seconds=x) for x in int_tests] results = [(now - td(seconds=x), td(seconds=x)) for x in int_tests] for t in (int_tests, date_tests, td_tests): for arg, result in zip(t, results): - dt, d = time.date_and_delta(arg) - self.assertEqualDatetime(dt, result[0]) + date, d = time.date_and_delta(arg) + self.assertEqualDatetime(date, result[0]) self.assertEqualTimedelta(d, result[1]) self.assertEqual(time.date_and_delta("NaN"), (None, "NaN")) @@ -49,12 +44,12 @@ class TimeTestCase(HumanizeTestCase): """Tests for the public interface of humanize.time""" def test_naturaldelta_nomonths(self): - now = datetime.now() + now = dt.datetime.now() test_list = [ - timedelta(days=7), - timedelta(days=31), - timedelta(days=230), - timedelta(days=400), + dt.timedelta(days=7), + dt.timedelta(days=31), + dt.timedelta(days=230), + dt.timedelta(days=400), ] result_list = [ "7 days", @@ -71,37 +66,37 @@ def nd_nomonths(d): self.assertManyResults(nd_nomonths, test_list, result_list) def test_naturaldelta(self): - now = datetime.now() + now = dt.datetime.now() test_list = [ 0, 1, 30, - timedelta(minutes=1, seconds=30), - timedelta(minutes=2), - timedelta(hours=1, minutes=30, seconds=30), - timedelta(hours=23, minutes=50, seconds=50), - timedelta(days=1), - timedelta(days=500), - timedelta(days=365 * 2 + 35), - timedelta(seconds=1), - timedelta(seconds=30), - timedelta(minutes=1, seconds=30), - timedelta(minutes=2), - timedelta(hours=1, minutes=30, seconds=30), - timedelta(hours=23, minutes=50, seconds=50), - timedelta(days=1), - timedelta(days=500), - timedelta(days=365 * 2 + 35), + dt.timedelta(minutes=1, seconds=30), + dt.timedelta(minutes=2), + dt.timedelta(hours=1, minutes=30, seconds=30), + dt.timedelta(hours=23, minutes=50, seconds=50), + dt.timedelta(days=1), + dt.timedelta(days=500), + dt.timedelta(days=365 * 2 + 35), + dt.timedelta(seconds=1), + dt.timedelta(seconds=30), + dt.timedelta(minutes=1, seconds=30), + dt.timedelta(minutes=2), + dt.timedelta(hours=1, minutes=30, seconds=30), + dt.timedelta(hours=23, minutes=50, seconds=50), + dt.timedelta(days=1), + dt.timedelta(days=500), + dt.timedelta(days=365 * 2 + 35), # regression tests for bugs in post-release humanize - timedelta(days=10000), - timedelta(days=365 + 35), + dt.timedelta(days=10000), + dt.timedelta(days=365 + 35), 30, - timedelta(days=365 * 2 + 65), - timedelta(days=365 + 4), - timedelta(days=35), - timedelta(days=65), - timedelta(days=9), - timedelta(days=365), + dt.timedelta(days=365 * 2 + 65), + dt.timedelta(days=365 + 4), + dt.timedelta(days=35), + dt.timedelta(days=65), + dt.timedelta(days=9), + dt.timedelta(days=365), "NaN", ] result_list = [ @@ -140,33 +135,33 @@ def test_naturaldelta(self): self.assertManyResults(time.naturaldelta, test_list, result_list) def test_naturaltime(self): - now = datetime.now() + now = dt.datetime.now() test_list = [ now, - now - timedelta(seconds=1), - now - timedelta(seconds=30), - now - timedelta(minutes=1, seconds=30), - now - timedelta(minutes=2), - now - timedelta(hours=1, minutes=30, seconds=30), - now - timedelta(hours=23, minutes=50, seconds=50), - now - timedelta(days=1), - now - timedelta(days=500), - now - timedelta(days=365 * 2 + 35), - now + timedelta(seconds=1), - now + timedelta(seconds=30), - now + timedelta(minutes=1, seconds=30), - now + timedelta(minutes=2), - now + timedelta(hours=1, minutes=30, seconds=30), - now + timedelta(hours=23, minutes=50, seconds=50), - now + timedelta(days=1), - now + timedelta(days=500), - now + timedelta(days=365 * 2 + 35), + now - dt.timedelta(seconds=1), + now - dt.timedelta(seconds=30), + now - dt.timedelta(minutes=1, seconds=30), + now - dt.timedelta(minutes=2), + now - dt.timedelta(hours=1, minutes=30, seconds=30), + now - dt.timedelta(hours=23, minutes=50, seconds=50), + now - dt.timedelta(days=1), + now - dt.timedelta(days=500), + now - dt.timedelta(days=365 * 2 + 35), + now + dt.timedelta(seconds=1), + now + dt.timedelta(seconds=30), + now + dt.timedelta(minutes=1, seconds=30), + now + dt.timedelta(minutes=2), + now + dt.timedelta(hours=1, minutes=30, seconds=30), + now + dt.timedelta(hours=23, minutes=50, seconds=50), + now + dt.timedelta(days=1), + now + dt.timedelta(days=500), + now + dt.timedelta(days=365 * 2 + 35), # regression tests for bugs in post-release humanize - now + timedelta(days=10000), - now - timedelta(days=365 + 35), + now + dt.timedelta(days=10000), + now - dt.timedelta(days=365 + 35), 30, - now - timedelta(days=365 * 2 + 65), - now - timedelta(days=365 + 4), + now - dt.timedelta(days=365 * 2 + 65), + now - dt.timedelta(days=365 + 4), "NaN", ] result_list = [ @@ -201,35 +196,35 @@ def test_naturaltime(self): self.assertManyResults(time.naturaltime, test_list, result_list) def test_naturaltime_nomonths(self): - now = datetime.now() + now = dt.datetime.now() test_list = [ now, - now - timedelta(seconds=1), - now - timedelta(seconds=30), - now - timedelta(minutes=1, seconds=30), - now - timedelta(minutes=2), - now - timedelta(hours=1, minutes=30, seconds=30), - now - timedelta(hours=23, minutes=50, seconds=50), - now - timedelta(days=1), - now - timedelta(days=17), - now - timedelta(days=47), - now - timedelta(days=500), - now - timedelta(days=365 * 2 + 35), - now + timedelta(seconds=1), - now + timedelta(seconds=30), - now + timedelta(minutes=1, seconds=30), - now + timedelta(minutes=2), - now + timedelta(hours=1, minutes=30, seconds=30), - now + timedelta(hours=23, minutes=50, seconds=50), - now + timedelta(days=1), - now + timedelta(days=500), - now + timedelta(days=365 * 2 + 35), + now - dt.timedelta(seconds=1), + now - dt.timedelta(seconds=30), + now - dt.timedelta(minutes=1, seconds=30), + now - dt.timedelta(minutes=2), + now - dt.timedelta(hours=1, minutes=30, seconds=30), + now - dt.timedelta(hours=23, minutes=50, seconds=50), + now - dt.timedelta(days=1), + now - dt.timedelta(days=17), + now - dt.timedelta(days=47), + now - dt.timedelta(days=500), + now - dt.timedelta(days=365 * 2 + 35), + now + dt.timedelta(seconds=1), + now + dt.timedelta(seconds=30), + now + dt.timedelta(minutes=1, seconds=30), + now + dt.timedelta(minutes=2), + now + dt.timedelta(hours=1, minutes=30, seconds=30), + now + dt.timedelta(hours=23, minutes=50, seconds=50), + now + dt.timedelta(days=1), + now + dt.timedelta(days=500), + now + dt.timedelta(days=365 * 2 + 35), # regression tests for bugs in post-release humanize - now + timedelta(days=10000), - now - timedelta(days=365 + 35), + now + dt.timedelta(days=10000), + now - dt.timedelta(days=365 + 35), 30, - now - timedelta(days=365 * 2 + 65), - now - timedelta(days=365 + 4), + now - dt.timedelta(days=365 * 2 + 65), + now - dt.timedelta(days=365 + 4), "NaN", ] result_list = [ @@ -272,15 +267,15 @@ def nt_nomonths(d): @freeze_time("2020-02-02") def test_naturalday(self): # Arrange - today = date.today() + today = dt.date.today() tomorrow = today + ONE_DAY yesterday = today - ONE_DAY - someday = date(today.year, 3, 5) + someday = dt.date(today.year, 3, 5) someday_result = "Mar 05" - valerrtest = fakedate(290149024, 2, 2) - overflowtest = fakedate(120390192341, 2, 2) + valerrtest = FakeDate(290149024, 2, 2) + overflowtest = FakeDate(120390192341, 2, 2) test_list = ( today, @@ -288,7 +283,7 @@ def test_naturalday(self): yesterday, someday, "02/26/1984", - (date(1982, 6, 27), "%Y.%m.%d"), + (dt.date(1982, 6, 27), "%Y.%m.%d"), None, "Not a date at all.", valerrtest, @@ -313,11 +308,11 @@ def test_naturalday(self): @freeze_time("2020-02-02") def test_naturaldate(self): # Arrange - today = date.today() + today = dt.date.today() tomorrow = today + ONE_DAY yesterday = today - ONE_DAY - someday = date(today.year, 3, 5) + someday = dt.date(today.year, 3, 5) someday_result = "Mar 05" test_list = ( @@ -325,7 +320,7 @@ def test_naturaldate(self): tomorrow, yesterday, someday, - date(1982, 6, 27), + dt.date(1982, 6, 27), None, "Not a date at all.", VALUE_ERROR_TEST, diff --git a/tox.ini b/tox.ini index c7e4ea88..511a4bc3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{27, 35, 36, 37, 38, py, py3} + py{35, 36, 37, 38, py3} [testenv] extras =