Skip to content

Commit

Permalink
updated test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
bashu committed Sep 29, 2015
1 parent eec5d01 commit a1515dc
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 37 deletions.
32 changes: 15 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@ language: python
python:
- "3.4"
- "3.3"
- "3.2"
- "2.7"
- "2.6"
- "pypy"
- "pypy3"
env:
- DJANGO_VERSION=1.4.21
- DJANGO_VERSION=1.5.12
- DJANGO_VERSION=1.6.11
- DJANGO_VERSION=1.7.9
- DJANGO_VERSION=1.8.3
install:
- DJANGO_VERSION=1.4.2
- DJANGO_VERSION=1.5
- DJANGO_VERSION=1.6
- DJANGO_VERSION=1.7
- DJANGO_VERSION=1.8
before_install:
- pip install -q django==$DJANGO_VERSION
- pip install -q -r example/requirements.txt
- pip install coveralls
install:
- python setup.py develop
- pip install -q coveralls
script:
- env PYTHONPATH=`pwd` coverage run --source=tz_detect example/manage.py test tz_detect
- coverage run --source=tz_detect setup.py test
after_success:
coveralls
matrix:
exclude:
- python: "pypy3"
env: DJANGO_VERSION=1.4.21
env: DJANGO_VERSION=1.4.2
- python: "3.4"
env: DJANGO_VERSION=1.4.21
env: DJANGO_VERSION=1.4.2
- python: "3.3"
env: DJANGO_VERSION=1.4.21
- python: "3.2"
env: DJANGO_VERSION=1.4.21
env: DJANGO_VERSION=1.4.2
- python: "2.6"
env: DJANGO_VERSION=1.7.9
env: DJANGO_VERSION=1.7
- python: "2.6"
env: DJANGO_VERSION=1.8.3
env: DJANGO_VERSION=1.8
44 changes: 44 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

import sys
from os import path

import django
from django.conf import settings, global_settings
from django.core.management import execute_from_command_line


if not settings.configured:
BASE_DIR = path.dirname(path.realpath(__file__))

settings.configure(
DEBUG = False,
TEMPLATE_DEBUG = True,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.sessions',
'django.contrib.contenttypes',

'tz_detect',
),
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'tz_detect.middleware.TimezoneMiddleware',
),
TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner' if django.VERSION < (1,6) else 'django.test.runner.DiscoverRunner',
SITE_ID = 1,
)

def runtests():
argv = sys.argv[:1] + ['test', 'tz_detect'] + sys.argv[1:]
execute_from_command_line(argv)

if __name__ == '__main__':
runtests()
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[wheel]
# create "py2.py3-none-any.whl" package
universal = 1
69 changes: 54 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,71 @@
#!/usr/bin/env python

import os
import re
import sys
import codecs
import subprocess

from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand


class TestRunner(TestCommand):
user_options = []

README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
def run(self):
raise SystemExit(subprocess.call([sys.executable, 'runtests.py']))

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

from tz_detect import __version__
def read(*parts):
file_path = os.path.join(os.path.dirname(__file__), *parts)
return codecs.open(file_path, encoding='utf-8').read()


def find_version(*parts):
version_file = read(*parts)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return str(version_match.group(1))
raise RuntimeError("Unable to find version string.")


setup(
name='django-tz-detect',
version=__version__,
packages=find_packages(exclude=['example']),
include_package_data=True,
version=find_version('tz_detect', '__init__.py'),
license='MIT License',

install_requires=[
'django>=1.4.2',
'pytz',
'six',
],
requires=[
'Django (>=1.4.2)',
],

description='Automatic user timezone detection for django',
long_description=README,
url='http://github.com/adamcharnock/django-tz-detect',
long_description=read('README.rst'),

author='Adam Charnock',
author_email='adam@adamcharnock.com',

maintainer='Basil Shubin',
maintainer_email='basil.shubin@gmail.com',
install_requires=[
'django>=1.4',
'pytz',
'six',
],

url='http://github.com/adamcharnock/django-tz-detect',
download_url='https://github.com/adamcharnock/django-tz-detect/zipball/master',

packages=find_packages(exclude=('example*', '*.tests*')),
include_package_data=True,

tests_require=[
],
cmdclass={
'test': TestRunner,
},

zip_safe=False,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
Expand All @@ -41,5 +81,4 @@
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
zip_safe=False,
)
4 changes: 1 addition & 3 deletions tz_detect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
VERSION = (0, 2, 5)

__version__ = '.'.join([str(n) for n in VERSION])
__version__ = '0.2.5'
4 changes: 2 additions & 2 deletions tz_detect/tests.py → tz_detect/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from django.test.client import RequestFactory
from django.contrib.sessions.middleware import SessionMiddleware

from .views import SetOffsetView
from .utils import offset_to_timezone
from ..views import SetOffsetView
from ..utils import offset_to_timezone


class ViewTestCase(TestCase):
Expand Down

0 comments on commit a1515dc

Please sign in to comment.