Skip to content

Commit

Permalink
Merge branch 'master' into using-strict-markup-in-readme
Browse files Browse the repository at this point in the history
Conflicts:
	README.rst
  • Loading branch information
waqasshabbir committed Jun 18, 2015
2 parents c21803b + ee2ec6f commit d8c6bb2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ language: python

python:
- "2.7"

env:
- TOXENV=py27
install:
- pip install -U wheel
- pip install -U tox
# command to run tests, e.g. python setup.py test
script: python setup.py test
script: tox

deploy:
provider: pypi
distributions: sdist bdist_wheel
user: scrapinghub
password:
secure: CJWIRI51KvqZrkPf7At1li+bbAZ/pN3iWRUPy0JaKWAC8O8B+GljXQxiXisPyLL1pIikcfLYZScOsKEhE+Uon/beeL1TPimVU3ELr7GYzuIkl3eK7quFUOiJ7glEggA5UyGNmk6goMVgaBQEOwT3gwH2LYwd1uFRvQsgIPY+tks=
secure: "Vs2Z69YTFzQWVkos7IvP4xk0RAQ35dzVXP+EAmzMkqi9qToTa7jdeF8deY18r3l8093jaJ/ct6NzjNiZ6ryWl1yKBwYoW+jaXjKGVXMFSQdqXiDreu516rqrOiRfZVHy+G9TabjhVrIW2npkxuOP7d0HONOZnNtCn6QrxQwEBzw="
on:
tags: true
repo: scrapinghub/dateparser
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ History

0.2.0 (2015-06-17)
------------------
* Easy to use `parse` function
* Languages definitions using YAML.
* Using translation based approach for parsing non-english languages. Previously, :mod:`dateutil.parserinfo` was used for language definitions.
* Better period extraction.
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ Also, it requires PyYAML_ for its language detection module to work.
Limitations
===========

`dateparser` at this point does not support generic parsing of dates with fixed UTC offsets. This restricts its ability to reliably parse time zone aware dates since the use of abbreviated time zones as a sole designator of time zones is not recommended.
* Only Python 2 support for now (Python 3 support **will be** added in future versions)

Read `Wikipedia Time Zone article`_ for more information.
* `dateparser` at this point does not support generic parsing of dates with fixed UTC offsets. This restricts its ability to reliably parse time zone aware dates since the use of abbreviated time zones as a sole designator of time zones is not recommended.

Read `Wikipedia Time Zone article`_ for more information.

.. _Wikipedia Time Zone Article: https://en.wikipedia.org/wiki/Time_zone#Abbreviations

20 changes: 15 additions & 5 deletions tests/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import re
import unittest
from collections import OrderedDict
from datetime import datetime, timedelta
Expand Down Expand Up @@ -473,25 +474,34 @@ def then_parsed_date_has_timezone(self):


class TestParserInitialization(BaseTestCase):
UNKNOWN_LANGUAGES_EXCEPTION_RE = re.compile(u"Unknown language\(s\): (.+)")

def setUp(self):
super(TestParserInitialization, self).setUp()
self.result = NotImplemented

@parameterized.expand([
param(['ur', 'li'], error_message=u"Unknown language(s): u'ur', u'li'"),
param(['ur', 'en'], error_message=u"Unknown language(s): u'ur'"),
param(['pk'], error_message=u"Unknown language(s): u'pk'"),
param(['ur', 'li'], unknown_languages=[u'ur', u'li']),
param(['ur', 'en'], unknown_languages=[u'ur']),
param(['pk'], unknown_languages=[u'pk']),
])
def test_should_raise_error_when_unknown_language_given(self, shortnames, error_message):
def test_should_raise_error_when_unknown_language_given(self, shortnames, unknown_languages):
self.when_parser_is_initialized(languages=shortnames)
self.then_error_was_raised(ValueError, error_message)
self.then_languages_are_unknown(unknown_languages)

def when_parser_is_initialized(self, **params):
try:
self.parser = date.DateDataParser(**params)
except Exception as error:
self.error = error

def then_languages_are_unknown(self, unknown_languages):
self.assertIsInstance(self.error, ValueError)
match = self.UNKNOWN_LANGUAGES_EXCEPTION_RE.match(str(self.error))
self.assertTrue(match)
languages = [shortname[2:-1] for shortname in match.group(1).split(", ")]
self.assertItemsEqual(languages, unknown_languages)


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ envlist = py27
deps =
-rrequirements.txt
-rtests/requirements.txt
commands = nosetests []
commands = nosetests -v tests []

0 comments on commit d8c6bb2

Please sign in to comment.