Skip to content

Commit cdba811

Browse files
committed
add test-py27
1 parent c76e092 commit cdba811

File tree

8 files changed

+47
-19
lines changed

8 files changed

+47
-19
lines changed

.circleci/config.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ jobs:
2727
pyenv shell py27 py37
2828
pip3 install tox
2929
tox
30+
test-py27:
31+
docker:
32+
- image: circleci/python:2.7
33+
user: root
34+
working_directory: ~/repo
35+
steps:
36+
- checkout
37+
- run:
38+
name: install dependencies
39+
command: pip install flake8 pytest pytest-cov && pip install --editable .
40+
- run:
41+
name: use flake8 check self
42+
command: flake8 .
43+
- run:
44+
name: run hobbit cmd
45+
command: hobbit --echo startproject -n demo -d ~/haha -f --example -p 1024
46+
- run:
47+
name: run tests
48+
environment:
49+
FLASK_APP: app/run.py
50+
FLASK_ENV: testing
51+
command: |
52+
cd ~/haha
53+
flask db init && flask db migrate && flask db upgrade
54+
flake8 . --exclude migrations
55+
py.test --cov . --cov-report term-missing -s
3056
test-py36:
3157
docker:
3258
- image: circleci/python:3.6
@@ -36,17 +62,13 @@ jobs:
3662
- checkout
3763
- run:
3864
name: install dependencies
39-
command: |
40-
pip install flake8 pytest pytest-cov
41-
pip install --editable .
65+
command: pip install flake8 pytest pytest-cov && pip install --editable .
4266
- run:
4367
name: use flake8 check self
44-
command: |
45-
flake8 .
68+
command: flake8 .
4669
- run:
4770
name: run hobbit cmd
48-
command: |
49-
hobbit --echo startproject -n demo -d ~/haha -f --example -p 1024
71+
command: hobbit --echo startproject -n demo -d ~/haha -f --example -p 1024
5072
- run:
5173
name: tree flask project
5274
command: |
@@ -72,18 +94,15 @@ jobs:
7294
- checkout
7395
- run:
7496
name: install dependencies
75-
command: |
76-
pip install flake8 pytest pytest-cov
77-
pip install --editable .
97+
command: pip install flake8 pytest pytest-cov && pip install --editable .
7898
- run:
7999
name: use flake8 check self
80-
command: |
81-
flake8 .
100+
command: flake8 .
82101
- run:
83102
name: run hobbit cmd
84103
command: |
85104
mkdir ~/haha && cd ~/haha
86-
hobbit --echo startproject -n demo -f --example -p 1024
105+
hobbit --echo startproject -n demo -f --example -p 1024
87106
- run:
88107
name: tree flask project
89108
command: |
@@ -106,6 +125,9 @@ workflows:
106125
test:
107126
jobs:
108127
- tox
128+
- test-py27:
129+
requires:
130+
- tox
109131
- test-py36:
110132
requires:
111133
- tox

hobbit_core/flask_hobbit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from flask import Flask
99

1010

11-
class HobbitManager:
11+
class HobbitManager(object):
1212
"""Customizable utils management.
1313
"""
1414

hobbit_core/flask_hobbit/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# -*- encoding: utf-8 -*-
12
import enum
23

34
from sqlalchemy import Integer, Column, ForeignKey, func, DateTime
45

56

6-
class SurrogatePK:
7+
class SurrogatePK(object):
78
"""A mixin that add ``id``、``created_at`` and ``updated_at`` columns
89
to any declarative-mapped class.
910

hobbit_core/flask_hobbit/err_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# -*- encoding: utf-8 -*-
12
from sqlalchemy.orm import exc as orm_exc
23

34
from .response import Result, ServerErrorResult, gen_response, RESP_MSGS
45

56

6-
class ErrHandler:
7+
class ErrHandler(object):
78
"""Base error handler that catch all exceptions. Be sure response is::
89
910
{

hobbit_core/flask_hobbit/pagination.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- encoding: utf-8 -*-
12
from collections import Mapping
23
from flask_sqlalchemy import model
34

hobbit_core/flask_hobbit/response.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- encoding: utf-8 -*-
12
from flask.json import dumps
23
from werkzeug import Response
34

@@ -41,7 +42,7 @@ def __init__(self, response=None, status=None, headers=None,
4142
direct_passthrough=False):
4243
assert sorted(response.keys()) == ['code', 'detail', 'message'], \
4344
'错误的返回格式'
44-
return super().__init__(
45+
return super(Result, self).__init__(
4546
response=dumps(response, indent=0, separators=(',', ':')) + '\n',
4647
status=status or self.status, headers=headers, mimetype=mimetype,
4748
content_type=content_type, direct_passthrough=direct_passthrough)
@@ -53,7 +54,7 @@ class SuccessResult(Result):
5354
status = 200
5455

5556
def __init__(self, code=None, message='', detail=None, status=None):
56-
return super().__init__(
57+
return super(SuccessResult, self).__init__(
5758
gen_response(code or self.status, message, detail),
5859
self.status or status)
5960

@@ -64,7 +65,7 @@ class FailedResult(Result):
6465
status = 400
6566

6667
def __init__(self, code=None, message='', detail=None):
67-
return super().__init__(
68+
return super(FailedResult, self).__init__(
6869
gen_response(code or self.status, message, detail), self.status)
6970

7071

hobbit_core/flask_hobbit/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- encoding: utf-8 -*-
12
from marshmallow import Schema, fields
23

34

hobbit_core/flask_hobbit/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- encoding: utf-8 -*-
12
import six
23

34

0 commit comments

Comments
 (0)