Skip to content

Commit

Permalink
fix travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Dec 28, 2017
1 parent 32e18b6 commit d0468b7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
language: python
env:
- TOXENV=flake8
- TOXENV=py27
- TOXENV=py34
- TOXENV=py35
- TOXENV=py36
- TOXENV=pypy
matrix:
include:
- python: 3.6
env: TOXENV=flake8
- python: 2.7
env: TOXENV=py27
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: pypy
env: TOXENV=pypy
install:
- pip install tox
script:
Expand Down
9 changes: 6 additions & 3 deletions flask_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ def include_jquery(version='2.1.0', local_js=None):
@staticmethod
def locale(language='en', auto_detect=False):
if auto_detect:
return Markup('<script>\nvar locale = window.navigator.userLanguage || window.navigator.language;\n'
return Markup('<script>\nvar locale = '
'window.navigator.userLanguage || '
'window.navigator.language;\n'
'moment.locale(locale);\n</script>')
else:
return Markup('<script>\nmoment.locale("%s");\n</script>' % language)

return Markup(
'<script>\nmoment.locale("%s");\n</script>' % language)

@staticmethod
def lang(language):
return _moment.locale(language)
Expand Down
10 changes: 4 additions & 6 deletions tests/test_flask_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,15 @@ def test__moment_local_true(self):

def test_locale(self):
mom = _moment_mock()
l = 'en'
locale = mom.locale(l)
locale = mom.locale('en')
assert isinstance(locale, Markup)
assert 'moment.locale("%s")' % l in str(locale)
assert 'moment.locale("en")' in str(locale)

def test_lang(self):
mom = _moment_mock()
l = 'en'
lang = mom.lang(l)
lang = mom.lang('en')
assert isinstance(lang, Markup)
assert 'moment.locale("%s")' % l in str(lang)
assert 'moment.locale("en")' in str(lang)

def test__moment_timestamp_passed(self):
ts = datetime(2017, 1, 15, 22, 47, 6, 479898)
Expand Down
6 changes: 6 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ deps=
pytest
pytest-cov
mock
basepython=
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
pypy: pypy

[testenv:flake8]
basepython=python3.6
Expand Down

0 comments on commit d0468b7

Please sign in to comment.