From 3e83d22db8859510e73ea61087e7b39d8fe238d9 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Tue, 4 Sep 2012 21:49:34 +0200 Subject: [PATCH] add travis.yaml --- .travis.yml | 15 +++++++++++++++ mapproxy/util/__init__.py | 24 +++++++++++++----------- requirements-tests.txt | 3 ++- requirements-travis.txt | 9 +++++++++ 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 .travis.yml create mode 100644 requirements-travis.txt diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..092e0a7cc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: python +python: + - "2.5" + - "2.6" + - "2.7" +services: + - couchdb +# command to install dependencies +install: + - "if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install --use-mirrors multiprocessing; fi" + - "if [[ $TRAVIS_PYTHON_VERSION != '2.5' ]]; then pip install requests==0.14.0; export MAPPROXY_TEST_COUCHDB=http://127.0.0.1:5984; fi" + - "sudo apt-get install libproj0 libgeos-dev libgdal-dev libxslt1-dev libxml2-dev build-essential python-dev libjpeg-dev zlib1g-dev libfreetype6-dev" + - "pip install -r requirements-travis.txt --use-mirrors" +# command to run tests +script: nosetests \ No newline at end of file diff --git a/mapproxy/util/__init__.py b/mapproxy/util/__init__.py index 2d2c8fbfa..6da39acc3 100644 --- a/mapproxy/util/__init__.py +++ b/mapproxy/util/__init__.py @@ -1,12 +1,12 @@ # This file is part of the MapProxy project. # Copyright (C) 2010 Omniscale -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,7 +30,7 @@ def local_base_config(conf): """ Temporarily set the global configuration (mapproxy.config.base_config). - + The global mapproxy.config.base_config object is thread-local and is set per-request in the MapProxyApp. Use `local_base_config` to set base_config outside of a request context (e.g. system loading @@ -97,9 +97,9 @@ def swap_dir(src_dir, dst_dir, keep_old=False, backup_ext='.tmp'): tmp_dir = dst_dir + backup_ext if os.path.exists(dst_dir): os.rename(dst_dir, tmp_dir) - + _force_rename_dir(src_dir, dst_dir) - + if os.path.exists(tmp_dir) and not keep_old: shutil.rmtree(tmp_dir) @@ -139,8 +139,10 @@ def timestamp_before(weeks=0, days=0, hours=0, minutes=0): def timestamp_from_isodate(isodate): """ - >>> timestamp_from_isodate('2009-06-09T10:57:00') - 1244537820.0 + >>> ts = timestamp_from_isodate('2009-06-09T10:57:00') + >>> # we don't know which timezone the test will run + >>> (1244537820.0 - 14 * 3600) < ts < (1244537820.0 + 14 * 3600) + True >>> timestamp_from_isodate('2009-06-09T10:57') #doctest: +ELLIPSIS Traceback (most recent call last): ... @@ -152,7 +154,7 @@ def timestamp_from_isodate(isodate): date = datetime.datetime.strptime(isodate, "%Y-%m-%dT%H:%M:%S") return time.mktime(date.timetuple()) -def cleanup_directory(directory, before_timestamp, remove_empty_dirs=True, +def cleanup_directory(directory, before_timestamp, remove_empty_dirs=True, file_handler=None): if file_handler is None: file_handler = os.remove @@ -173,7 +175,7 @@ def cleanup_directory(directory, before_timestamp, remove_empty_dirs=True, if remove_empty_dirs: remove_dir_if_emtpy(dirpath) - + if remove_empty_dirs: remove_dir_if_emtpy(directory) @@ -199,7 +201,7 @@ def ensure_directory(file_name): def replace_instancemethod(old_method, new_method): """ Replace an instance method. - + >>> class Foo(object): ... val = 'bar' ... def bar(self): diff --git a/requirements-tests.txt b/requirements-tests.txt index d48690beb..3ac4f33b3 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,4 +1,5 @@ -WebTest>=1.2.2 +WebTest>=1.2.2,<1.2.99 +webob==1.1.1 coverage>=2.85 lxml>=2.1.3 mocker>=0.10.1 diff --git a/requirements-travis.txt b/requirements-travis.txt new file mode 100644 index 000000000..dc47f9b9c --- /dev/null +++ b/requirements-travis.txt @@ -0,0 +1,9 @@ +WebTest==1.4.0 +webob==1.1.1 +lxml==2.3.5 +mocker==1.1.1 +nose==1.1.2 +Shapely==1.2.15 +PyYAML==3.10 +Pillow==1.7.7 +eventlet==0.9.17 \ No newline at end of file