Skip to content

Commit 26260b9

Browse files
authored
Close joke2k#912. Skip tests on 32bit systems (joke2k#922)
1 parent 5f3bc39 commit 26260b9

File tree

8 files changed

+62
-14
lines changed

8 files changed

+62
-14
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.git/
2+
3+
build
4+
dist
5+
*.egg-info
6+
*.egg/
7+
*.pyc
8+
*.swp
9+
10+
.tox
11+
.coverage
12+
html/*
13+
__pycache__
14+
15+
# Compiled Documentation
16+
docs/_build

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ branches:
88

99
matrix:
1010
include:
11+
- python: 3.7
12+
env: TOXENV=flake8
13+
- python: 3.7
14+
env: TOXENV=checkmanifest
1115
- python: 2.7
1216
env: TOXENV=py27
1317
- python: 3.4
@@ -23,9 +27,8 @@ matrix:
2327
- python: pypy3.5-6.0
2428
env: TOXENV=pypy3
2529
- python: 3.7
26-
env: TOXENV=flake8
27-
- python: 3.7
28-
env: TOXENV=checkmanifest
30+
os: linux
31+
env: TOXENV=32bit
2932

3033
install:
3134
- pip install tox

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ recursive-include tests *.json
77
recursive-include tests *.py
88

99
global-exclude *.py[cod] __pycache__ *.so
10-
exclude Makefile tox.ini .coveragerc .bumpversion.cfg
10+
exclude Makefile tox.ini .coveragerc .bumpversion.cfg .dockerignore
1111
exclude ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md
1212
exclude appveyor.yml readthedocs.yml
13+
exclude build32bit.sh
1314
prune docs
1415
prune .circleci
1516

build32bit.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
docker run -v ${PWD}:/code -e INSTALL_REQUIREMENTS=${INSTALL_REQUIREMENTS} i386/ubuntu bash -c "
4+
apt-get update \
5+
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq python3 locales python3-pip debianutils \
6+
&& pip3 install tox coveralls \
7+
&& locale-gen en_US.UTF-8 \
8+
&& cd /code \
9+
&& coverage run --source=faker setup.py test \
10+
&& coverage report"

faker/providers/date_time/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from dateutil import relativedelta
1212
from dateutil.tz import tzlocal, tzutc
1313

14-
from faker.utils.datetime_safe import date, datetime, real_date, real_datetime
1514
from faker.utils import is_string
15+
from faker.utils.datetime_safe import date, datetime, real_date, real_datetime
1616

1717
from .. import BaseProvider
1818

@@ -1664,11 +1664,17 @@ def date_time_between_dates(
16641664
datetime_to_timestamp(datetime_start),
16651665
datetime_to_timestamp(datetime_end),
16661666
)
1667-
if tzinfo is None:
1668-
pick = datetime.fromtimestamp(timestamp, tzlocal())
1669-
pick = pick.astimezone(tzutc()).replace(tzinfo=None)
1670-
else:
1671-
pick = datetime.fromtimestamp(timestamp, tzinfo)
1667+
try:
1668+
if tzinfo is None:
1669+
pick = datetime.fromtimestamp(timestamp, tzlocal())
1670+
pick = pick.astimezone(tzutc()).replace(tzinfo=None)
1671+
else:
1672+
pick = datetime.fromtimestamp(timestamp, tzinfo)
1673+
except OverflowError:
1674+
raise OverflowError(
1675+
"You specified an end date with a timestamp bigger than the maximum allowed on this"
1676+
" system. Please specify an earlier date.",
1677+
)
16721678
return pick
16731679

16741680
def date_between_dates(self, date_start=None, date_end=None):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
'Topic :: Software Development :: Libraries :: Python Modules',
5151
'Topic :: Software Development :: Testing',
5252
'Topic :: Utilities',
53-
'License :: OSI Approved :: MIT License'
53+
'License :: OSI Approved :: MIT License',
5454
],
5555
keywords='faker fixtures data test mock generator',
5656
author='joke2k',
@@ -80,5 +80,5 @@
8080
':python_version=="2.7"': [
8181
'ipaddress',
8282
],
83-
}
83+
},
8484
)

tests/providers/test_date_time.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import time
77
import unittest
88
import random
9+
import sys
910

1011
import six
1112

@@ -18,6 +19,10 @@
1819
import pytest
1920

2021

22+
def is64bit():
23+
return sys.maxsize > 2**32
24+
25+
2126
class UTC(tzinfo):
2227
"""
2328
UTC implementation taken from Python's docs.
@@ -225,6 +230,7 @@ def test_date_between_dates(self):
225230
def _datetime_to_time(self, value):
226231
return int(time.mktime(value.timetuple()))
227232

233+
@unittest.skipUnless(is64bit(), "requires 64bit")
228234
def test_date_time_this_period(self):
229235
# test century
230236
this_century_start = self._datetime_to_time(
@@ -292,6 +298,7 @@ def test_date_time_this_period(self):
292298
self._datetime_to_time(datetime.now())
293299
)
294300

301+
@unittest.skipUnless(is64bit(), "requires 64bit")
295302
def test_date_time_this_period_with_tzinfo(self):
296303
# ensure all methods provide timezone aware datetimes
297304
with pytest.raises(TypeError):
@@ -329,6 +336,7 @@ def test_date_time_this_period_with_tzinfo(self):
329336
replace(second=0, microsecond=0) == datetime.now(utc).replace(second=0, microsecond=0)
330337
)
331338

339+
@unittest.skipUnless(is64bit(), "requires 64bit")
332340
def test_date_this_period(self):
333341
# test century
334342
assert self.factory.date_this_century(after_today=False) <= date.today()

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist=py{27,34,35,36,37,py,py3},flake8,checkmanifest
2+
envlist=py{27,34,35,36,37,py,py3},32bit,flake8,checkmanifest
33
skip_missing_interpreters = true
44

55
[testenv]
@@ -24,6 +24,10 @@ deps =
2424
commands =
2525
check-manifest
2626

27+
[testenv:32bit]
28+
basepython = python
29+
commands = ./build32bit.sh
30+
2731
[flake8]
2832
max-line-length = 120
29-
exclude = faker/lib,faker/bin
33+
exclude = faker/lib,faker/bin,.eggs,docs

0 commit comments

Comments
 (0)