Repository: joke2k/faker

Issue:
Tests fail on 32bit platforms
When running tests on 32bit platform the time check actually overflows :)

### Steps to reproduce

Run tests on 32bit platform

### Expected behavior

Tests pass

### Actual behavior

Test fail, see full build log: 
[faker.txt](https://github.com/joke2k/faker/files/2868550/faker.txt)



Discussion:
Thank you for the report @scarabeusiv 

Sadl, we really don't have a way to test on 32bit platforms, so we can't support it. But we will accept a Pull Request if you'd have the time to work on it :)
Advice at https://github.com/travis-ci/travis-ci/issues/5770 and predecessor is to use 32bit docker images.
Problem in this case is that 32bit clocks give up in 2038+- and the test expects "datetime_end = date(2100, 1, 1)" which overflows the container on 32bit machine.

You can either lower the check on the date, or skip those tests on 32bit.
@jayvdb could you submit a PR to add a 32bit build on travis?
My opinion is that if we can't test on 32bit systems on the CI, we should just be upfront and declare Faker as 64bit-only

Resolving patch:
diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py
--- a/faker/providers/date_time/__init__.py
+++ b/faker/providers/date_time/__init__.py
@@ -11,8 +11,8 @@
 from dateutil import relativedelta
 from dateutil.tz import tzlocal, tzutc
 
-from faker.utils.datetime_safe import date, datetime, real_date, real_datetime
 from faker.utils import is_string
+from faker.utils.datetime_safe import date, datetime, real_date, real_datetime
 
 from .. import BaseProvider
 
@@ -1664,11 +1664,17 @@ def date_time_between_dates(
             datetime_to_timestamp(datetime_start),
             datetime_to_timestamp(datetime_end),
         )
-        if tzinfo is None:
-            pick = datetime.fromtimestamp(timestamp, tzlocal())
-            pick = pick.astimezone(tzutc()).replace(tzinfo=None)
-        else:
-            pick = datetime.fromtimestamp(timestamp, tzinfo)
+        try:
+            if tzinfo is None:
+                pick = datetime.fromtimestamp(timestamp, tzlocal())
+                pick = pick.astimezone(tzutc()).replace(tzinfo=None)
+            else:
+                pick = datetime.fromtimestamp(timestamp, tzinfo)
+        except OverflowError:
+            raise OverflowError(
+                "You specified an end date with a timestamp bigger than the maximum allowed on this"
+                " system. Please specify an earlier date.",
+            )
         return pick
 
     def date_between_dates(self, date_start=None, date_end=None):
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -50,7 +50,7 @@
         'Topic :: Software Development :: Libraries :: Python Modules',
         'Topic :: Software Development :: Testing',
         'Topic :: Utilities',
-        'License :: OSI Approved :: MIT License'
+        'License :: OSI Approved :: MIT License',
     ],
     keywords='faker fixtures data test mock generator',
     author='joke2k',
@@ -80,5 +80,5 @@
         ':python_version=="2.7"': [
             'ipaddress',
         ],
-    }
+    },
 )


Test patch:
diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py
--- a/tests/providers/test_date_time.py
+++ b/tests/providers/test_date_time.py
@@ -6,6 +6,7 @@
 import time
 import unittest
 import random
+import sys
 
 import six
 
@@ -18,6 +19,10 @@
 import pytest
 
 
+def is64bit():
+    return sys.maxsize > 2**32
+
+
 class UTC(tzinfo):
     """
     UTC implementation taken from Python's docs.
@@ -225,6 +230,7 @@ def test_date_between_dates(self):
     def _datetime_to_time(self, value):
         return int(time.mktime(value.timetuple()))
 
+    @unittest.skipUnless(is64bit(), "requires 64bit")
     def test_date_time_this_period(self):
         # test century
         this_century_start = self._datetime_to_time(
@@ -292,6 +298,7 @@ def test_date_time_this_period(self):
             self._datetime_to_time(datetime.now())
         )
 
+    @unittest.skipUnless(is64bit(), "requires 64bit")
     def test_date_time_this_period_with_tzinfo(self):
         # ensure all methods provide timezone aware datetimes
         with pytest.raises(TypeError):
@@ -329,6 +336,7 @@ def test_date_time_this_period_with_tzinfo(self):
             replace(second=0, microsecond=0) == datetime.now(utc).replace(second=0, microsecond=0)
         )
 
+    @unittest.skipUnless(is64bit(), "requires 64bit")
     def test_date_this_period(self):
         # test century
         assert self.factory.date_this_century(after_today=False) <= date.today()