Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a14108
commit 3f3a4c5
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
import arrow | ||
from .core import Mode | ||
from . import _arrow as arrow | ||
from . import _arrow | ||
|
||
__version__ = "0.0.2" | ||
__all__ = ["Mode", "arrow"] | ||
__version__ = "0.0.3" | ||
__all__ = ["Mode", "near"] | ||
|
||
|
||
def near(obj, *args, **kwargs): | ||
if isinstance(obj, arrow.Arrow): | ||
if args: | ||
raise ValueError("near(arrow.Arrow) only takes one datetime") | ||
return _arrow.near(obj, **kwargs) | ||
else: | ||
raise NotImplementedError( | ||
"roughly is still under development - make a request!" | ||
" https://github.com/numberoverzero/roughly/issues/new") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import arrow | ||
import pytest | ||
from roughly import near | ||
|
||
|
||
def test_near_arrow(): | ||
now = arrow.now() | ||
not_now = now.replace(seconds=1) | ||
roughly_now = near(not_now, seconds=5) | ||
assert roughly_now == now | ||
|
||
|
||
def test_near_arrow_args(): | ||
"""_arrow.near only takes one positional arg""" | ||
with pytest.raises(ValueError): | ||
near(arrow.now(), "extra posarg") | ||
|
||
|
||
def test_not_implemented(): | ||
obj = object() | ||
with pytest.raises(NotImplementedError) as excinfo: | ||
near(obj) | ||
new_issue_url = "https://github.com/numberoverzero/roughly/issues/new" | ||
assert new_issue_url in str(excinfo.value) |