Skip to content

Commit

Permalink
Remove utcnow() deprecation warning in test (#721)
Browse files Browse the repository at this point in the history
* Remove utcnow() deprecation warning in test

* Update tox.ini for py38,py310

* Update CHANGES

* Update base.py

* Update README.md

* Update CHANGES

* Update README.md

* Update tox.ini

* Update appveyor.yml

* Update appveyor.yml
  • Loading branch information
nicozanf authored Nov 29, 2024
1 parent 7f5fd21 commit 4dda912
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Thumbs.db
.DS_Store
pyDAL.egg-info/*
venv/*
test-venv/*
dist/*
build/*
.project
Expand Down
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pyDAL changelog
===============

TEST2
Version 18.0

Released on December 27th 2019
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyDAL
# pyDAL test 3

[![pip version](https://img.shields.io/pypi/v/pydal.svg?style=flat-square)](https://pypi.python.org/pypi/pydal)
[![master-test](https://github.com/web2py/pydal/actions/workflows/run_test.yaml/badge.svg)](https://github.com/web2py/pydal/actions/workflows/run_test.yaml)
Expand All @@ -12,7 +12,7 @@ What makes pyDAL different from most of the other DALs is the syntax: it maps re

Historically pyDAL comes from the original web2py's DAL, with the aim of being compatible with any Python program. However, pyDAL nowadays is an indipendent package that can be used in any Python 3.7+ context.

## Installation
## Installation test

You can install pyDAL using `pip`:

Expand Down
28 changes: 5 additions & 23 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,12 @@ services:

environment:
matrix:
- PYTHON: "C:/Python27"
PY_VER: "2.7"
adapter: "mssql"
- PYTHON: "C:/Python27"
PY_VER: "2.7"
adapter: "mssqln"
- PYTHON: "C:/Python34"
PY_VER: "3.4"
adapter: "mssql"
- PYTHON: "C:/Python34"
PY_VER: "3.4"
adapter: "mssqln"
- PYTHON: "C:/Python35"
PY_VER: "3.5"
adapter: "mssql"
- PYTHON: "C:/Python35"
PY_VER: "3.5"
adapter: "mssqln"
- PYTHON: "C:/Python36-x64"
PY_VER: "3.6"
- PYTHON: "C:/Python38-x64"
PY_VER: "3.8"
PYTHON_ARCH: "64"
adapter: "mssql"
- PYTHON: "C:/Python36-x64"
PY_VER: "3.6"
- PYTHON: "C:/Python38-x64"
PY_VER: "3.8"
PYTHON_ARCH: "64"
adapter: "mssqln"

Expand All @@ -39,7 +21,7 @@ init:
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%

install:
- appveyor DownloadFile https://bootstrap.pypa.io/pip/%PY_VER%/get-pip.py
- appveyor DownloadFile https://bootstrap.pypa.io/pip/get-pip.py
- python get-pip.py
- pip install tox==1.9.2
- pip install codecov
Expand Down
2 changes: 1 addition & 1 deletion pydal/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
)
)


# TESTING
class MetaDAL(type):
def __call__(cls, *args, **kwargs):
#: intercept arguments for DAL customisation on call
Expand Down
4 changes: 2 additions & 2 deletions pydal/restapi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import collections
import copy
import datetime
import fnmatch
import functools
import re
import traceback
from .utils import utcnow

__version__ = "0.1"

Expand Down Expand Up @@ -67,7 +67,7 @@ def wrapper(*args, **kwargs):
data["message"] = str(e)
data["code"] = 400
finally:
data["timestamp"] = datetime.datetime.utcnow().isoformat()
data["timestamp"] = utcnow().isoformat()
data["api_version"] = __version__
return data

Expand Down
3 changes: 2 additions & 1 deletion pydal/tools/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

from pydal import DAL, Field
from pydal.validators import IS_IN_SET
from utils import utcnow


def now():
"""Returns the current datetime in UTC"""
return datetime.datetime.utcnow()
return utcnow()


def delta(t_secs):
Expand Down
5 changes: 4 additions & 1 deletion pydal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@

import re
import warnings

import datetime

class RemovedInNextVersionWarning(DeprecationWarning):
pass


warnings.simplefilter("always", RemovedInNextVersionWarning)

def utcnow():
"""returns the current time in utc"""
return datetime.datetime.now(datetime.timezone.utc)

def warn_of_deprecation(old_name, new_name, prefix=None, stack=2):
msg = "%(old)s is deprecated, use %(new)s instead."
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tox]
envlist = {py27,pypy,pypy3,py33,py34,py35,py36}-{sqlite,mongo,mysql,oracle}, {py27,py33,py34}-{postgres,postgres3}, py27-{google,mssql}
envlist = {py38,py310}-{sqlite,mongo,mysql,oracle}, {py38,py310}-{postgres,postgres3}, {py38,py310}-{google,mssql}
skipsdist = True

[testenv]
passenv = ORACLE_HOME ORACLE_BASE LD_LIBRARY_PATH NLS_LANG ORACLE_SID
Expand All @@ -24,7 +25,7 @@ deps =
coverage: coverage
oracle: cx_Oracle
commands =
py27,pypy,pypy3,py33,py34,py35,py36: {envpython} -m unittest -v -f tests
py38,py10: {envpython} -m unittest -v -f tests
coverage: coverage erase
coverage: coverage run -m unittest -v -f tests
coverage: coverage combine

0 comments on commit 4dda912

Please sign in to comment.