- Add patch to fix 32bit builds:
* faker-32bit.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Faker?expand=0&rev=19
This commit is contained in:
parent
d40ed99efa
commit
5717d27503
102
faker-32bit.patch
Normal file
102
faker-32bit.patch
Normal file
@ -0,0 +1,102 @@
|
||||
From 26260b97bee18e2b1ace7cd0f450215f35fd667e Mon Sep 17 00:00:00 2001
|
||||
From: Flavio Curella <89607+fcurella@users.noreply.github.com>
|
||||
Date: Mon, 11 Mar 2019 13:38:18 -0500
|
||||
Subject: [PATCH] Close #912. Skip tests on 32bit systems (#922)
|
||||
|
||||
---
|
||||
.dockerignore | 16 ++++++++++++++++
|
||||
.travis.yml | 9 ++++++---
|
||||
MANIFEST.in | 3 ++-
|
||||
build32bit.sh | 10 ++++++++++
|
||||
faker/providers/date_time/__init__.py | 18 ++++++++++++------
|
||||
setup.py | 4 ++--
|
||||
tests/providers/test_date_time.py | 8 ++++++++
|
||||
tox.ini | 8 ++++++--
|
||||
8 files changed, 62 insertions(+), 14 deletions(-)
|
||||
create mode 100644 .dockerignore
|
||||
create mode 100755 build32bit.sh
|
||||
|
||||
diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py
|
||||
index ed27c9f4..7158307a 100644
|
||||
--- 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/tests/providers/test_date_time.py b/tests/providers/test_date_time.py
|
||||
index 6f80ed54..67c974cb 100644
|
||||
--- 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()
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 12 09:24:13 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
|
||||
|
||||
- Add patch to fix 32bit builds:
|
||||
* faker-32bit.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Mar 10 10:15:00 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
|
@ -26,6 +26,7 @@ License: MIT
|
||||
Group: Development/Languages/Python
|
||||
URL: https://github.com/joke2k/faker
|
||||
Source: https://files.pythonhosted.org/packages/source/F/Faker/Faker-%{version}.tar.gz
|
||||
Patch0: faker-32bit.patch
|
||||
BuildRequires: %{python_module UkPostcodeParser >= 1.1.1}
|
||||
BuildRequires: %{python_module email_validator >= 1.0.2}
|
||||
BuildRequires: %{python_module mock}
|
||||
@ -67,6 +68,7 @@ testing, and data anonymization from production services.
|
||||
find . -name '*.py[co]' -delete
|
||||
# do not hardcode pytest version
|
||||
sed -i -e 's:"pytest>=3.8.0,<3.9":"pytest>=3.8.0":g' setup.py
|
||||
%patch0 -p1
|
||||
|
||||
%build
|
||||
%python_build
|
||||
|
Loading…
Reference in New Issue
Block a user