Skip to content

Commit

Permalink
Made a number of tweaks to the MANIFEST and tweaked a few error messa…
Browse files Browse the repository at this point in the history
…ges (arrow-py#649)

* Made a number of tweaks to the MANIFEST and tweaked a few error messages

* Added Docs back to manifest

* Added mock to tests_require
  • Loading branch information
jadchaar authored and systemcatch committed Aug 27, 2019
1 parent 52354fe commit 0861bbe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include LICENSE HISTORY.md README.rst
recursive-include tests *
recursive-include docs *
include LICENSE CHANGELOG.md README.rst
recursive-include tests *.py
recursive-include docs *.py *.rst *.bat Makefile
11 changes: 8 additions & 3 deletions arrow/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def shift(self, **kwargs):
""" Returns a new :class:`Arrow <arrow.arrow.Arrow>` object with attributes updated
according to inputs.
Use pluralized property names to shift their current value relatively:
Use pluralized property names to relatively shift their current value:
>>> import arrow
>>> arw = arrow.utcnow()
Expand All @@ -642,13 +642,18 @@ def shift(self, **kwargs):
"""

relative_kwargs = {}
additional_attrs = ["weeks", "quarters", "weekday"]

for key, value in kwargs.items():

if key in self._ATTRS_PLURAL or key in ["weeks", "quarters", "weekday"]:
if key in self._ATTRS_PLURAL or key in additional_attrs:
relative_kwargs[key] = value
else:
raise AttributeError()
raise AttributeError(
"Invalid shift time frame. Please select one of the following: {}.".format(
", ".join(self._ATTRS_PLURAL + additional_attrs)
)
)

# core datetime does not support quarters, translate to months.
relative_kwargs.setdefault("months", 0)
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backports.functools_lru_cache==1.5.0
backports.functools_lru_cache==1.5.0; python_version == "2.7"
chai==1.1.2
mock==3.0.*
nose==1.3.7
Expand All @@ -7,5 +7,5 @@ pre-commit==1.18.*
python-dateutil==2.8.*
pytz==2019.*
simplejson==3.16.*
sphinx==1.8.*; python_version == '2.7'
sphinx==2.2.*; python_version >= '3.5'
sphinx==1.8.*; python_version == "2.7"
sphinx==2.2.*; python_version >= "3.5"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
description="Better dates & times for Python",
long_description=readme,
long_description_content_type="text/x-rst",
url="https://arrow.readthedocs.io/en/latest/",
url="https://arrow.readthedocs.io",
author="Chris Smith",
author_email="crsmithdev@gmail.com",
license="Apache 2.0",
Expand All @@ -28,7 +28,7 @@
"backports.functools_lru_cache>=1.2.1;python_version=='2.7'",
],
test_suite="tests",
tests_require=["chai"],
tests_require=["chai", "mock"],
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand Down
7 changes: 6 additions & 1 deletion tests/arrow_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,13 @@ def test_replace_other_kwargs(self):
class ArrowShiftTests(Chai):
def test_not_attr(self):

now = arrow.Arrow.utcnow()

with self.assertRaises(AttributeError):
now.shift(abc=1)

with self.assertRaises(AttributeError):
arrow.Arrow.utcnow().shift(abc=1)
now.shift(week=1)

def test_shift(self):

Expand Down

0 comments on commit 0861bbe

Please sign in to comment.