Only test modern python/django versions (#3)

This commit drops support for Python 2.

Fixes #1.
This commit is contained in:
Guanzhong Chen 2020-05-22 23:12:16 -04:00 committed by GitHub
parent cdb265a97a
commit f79ac251c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 17 deletions

View file

@ -1,25 +1,20 @@
language: python language: python
python: python:
- "2.7"
- "3.4"
- "3.5" - "3.5"
- "3.6" - "3.6"
- "3.7"
- "3.8"
env: env:
- DJANGO_VERSION="" - DJANGO_VERSION=""
- DJANGO_VERSION=">=1.8,<1.9"
- DJANGO_VERSION=">=1.9,<1.10"
- DJANGO_VERSION=">=1.10,<1.11"
- DJANGO_VERSION=">=1.11,<2" - DJANGO_VERSION=">=1.11,<2"
- DJANGO_VERSION=">=2,<2.1" - DJANGO_VERSION=">=2,<2.1"
- DJANGO_VERSION=">=2.1,<2.2" - DJANGO_VERSION=">=2.1,<2.2"
- DJANGO_VERSION=">=2.2,<3"
- DJANGO_VERSION=">=3,<3.1"
matrix: matrix:
exclude: exclude:
- python: "2.7" - python: "3.5"
env: DJANGO_VERSION=">=2,<2.1" env: DJANGO_VERSION=">=3,<3.1"
- python: "2.7"
env: DJANGO_VERSION=">=2.1,<2.2"
- python: "3.4"
env: DJANGO_VERSION=">=2.1,<2.2"
install: install:
- pip install codecov $([ -n "$DJANGO_VERSION" ] && echo "Django$DJANGO_VERSION") - pip install codecov $([ -n "$DJANGO_VERSION" ] && echo "Django$DJANGO_VERSION")
script: script:

View file

@ -1,17 +1,16 @@
import inspect import inspect
import logging import logging
import os import os
import time
from copy import copy from copy import copy
from functools import wraps from functools import wraps
from numbers import Number from numbers import Number
from time import perf_counter
from optimize_later.config import global_callback from optimize_later.config import global_callback
from optimize_later.utils import NoArgDecoratorMeta, with_metaclass from optimize_later.utils import NoArgDecoratorMeta, with_metaclass
from optimize_later import utils from optimize_later import utils
log = logging.getLogger(__name__.rpartition('.')[0] or __name__) log = logging.getLogger(__name__.rpartition('.')[0] or __name__)
timer = [time.time, time.clock][os.name == 'nt']
def _generate_default_name(): def _generate_default_name():
@ -39,11 +38,11 @@ class OptimizeBlock(object):
def __enter__(self): def __enter__(self):
assert self.start is None, 'Do not reuse blocks.' assert self.start is None, 'Do not reuse blocks.'
self.start = timer() self.start = perf_counter()
return self return self
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
self.end = timer() self.end = perf_counter()
self.delta = self.end - self.start self.delta = self.end - self.start
def short(self, precision=3): def short(self, precision=3):
@ -115,11 +114,11 @@ class optimize_later(with_metaclass(NoArgDecoratorMeta)):
def __enter__(self): def __enter__(self):
assert self.start is None, 'Do not reuse optimize_later objects.' assert self.start is None, 'Do not reuse optimize_later objects.'
self.start = timer() self.start = perf_counter()
return self return self
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
self.end = timer() self.end = perf_counter()
self.delta = self.end - self.start self.delta = self.end - self.start
if self.delta >= self.limit: if self.delta >= self.limit:
self._report() self._report()