Skip to content

Commit

Permalink
Merge pull request #260 from jathanism/pretty_time
Browse files Browse the repository at this point in the history
Fixes #259 - Fixed ImportError in trigger.utils.cli.pretty_time()
  • Loading branch information
johnfzc committed Mar 28, 2016
2 parents 2fb4e85 + 3ece46a commit 3e02b18
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ python:
- "2.7"

install:
- pip install . --use-mirrors
- pip install -r requirements-dev.txt
- pip install .

env:
- TRIGGER_SETTINGS=tests/data/settings.py

script:
- python setup.py nosetests
- py.test -vv tests/
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
Changelog
=========

.. _v1.5.9:

1.5.9 (??)
==========

Bug Fixes
---------

+ :bug:`259` - Bugfix in `~trigger.utils.core.pretty_time()` where ``pytz`` was
being referenced but not imported.

.. _v1.5.8:

1.5.8 (2016-03-08)
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
python_paths = .
addopts = -v
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
py==1.4.30
pytest==2.8.2
pytest-pythonpath==0.7
12 changes: 12 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import datetime
from pytz import timezone
from trigger.utils import cli


def test_pretty_time():
"""Test that ``pretty_time`` works()."""
now = datetime.datetime.now(timezone('US/Pacific'))
tomorrow = now + datetime.timedelta(days=1)
pretty = cli.pretty_time(tomorrow)
assert 'tomorrow' in pretty
2 changes: 1 addition & 1 deletion trigger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = (1, 5, 8)
__version__ = (1, 5, 9)

full_version = '.'.join(str(x) for x in __version__[0:3]) + \
''.join(__version__[3:])
Expand Down
1 change: 1 addition & 0 deletions trigger/gorc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
The only public interface to this module is `~trigger.gorc.get_init_commands`.
Given a ``.gorc`` That looks like this::
[init_commands]
cisco:
term mon
terminal length 0
Expand Down
4 changes: 2 additions & 2 deletions trigger/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from fcntl import ioctl
import os
import pwd
from pytz import timezone
from pytz import timezone, UTC
import struct
import sys
import termios
Expand Down Expand Up @@ -173,7 +173,7 @@ def pretty_time(t):
# calculate naive 'now' in local time
# passing localzone into datetime.now directly can cause
# problems, see the 'pytz' docs if curious
now = datetime.datetime.now(pytz.UTC)
now = datetime.datetime.now(UTC)
now = now.astimezone(localzone)
now = now.replace(tzinfo=None)
# and compute midnight
Expand Down

0 comments on commit 3e02b18

Please sign in to comment.