Skip to content

Commit 1a45cd8

Browse files
Merge 6ca62f4 into 8867540
2 parents 8867540 + 6ca62f4 commit 1a45cd8

File tree

7 files changed

+71
-66
lines changed

7 files changed

+71
-66
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exclude_lines =
1919
except OSError
2020

2121
# Don't complain if non-runnable code isn't run:
22-
if __name__ in u'__main__':
22+
if __name__ in '__main__':
2323

2424
ignore_errors = True
2525

.travis.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ matrix:
1818
python: "2.7"
1919
env: TRAVIS_PYTHON_VERSION="2.7"
2020
dist: trusty
21+
- os: linux
22+
python: "3.2"
23+
env: TRAVIS_PYTHON_VERSION="3.2"
2124
- os: linux
2225
python: "3.3"
2326
env: TRAVIS_PYTHON_VERSION="3.3"
@@ -44,11 +47,11 @@ matrix:
4447
python: "3.8-dev"
4548
env: TRAVIS_PYTHON_VERSION="3.8"
4649
- os: linux
47-
python: "pypy" # PyPy2 2.5.0
50+
python: "pypy2.7-5.8.0"
4851
- os: linux
49-
python: "pypy3"
52+
python: "pypy3.5-5.8.0"
5053
- os: linux
51-
python: "pypy-5.3.1"
54+
python: "pypy3.5-6.0"
5255
- os: linux
5356
python: "nightly" # currently points to 3.7-dev
5457
env: TRAVIS_PYTHON_VERSION="3.7-dev"
@@ -67,6 +70,12 @@ matrix:
6770
- os: osx
6871
osx_image: xcode9
6972
language: generic
73+
- os: osx
74+
osx_image: xcode9.2
75+
language: generic
76+
- os: osx
77+
osx_image: xcode9.3
78+
language: generic
7079
allow_failures:
7180
- os: linux
7281
python: "nightly" # currently points to 3.7-dev
@@ -94,7 +103,11 @@ matrix:
94103
- os: linux
95104
python: "pypy3"
96105
- os: linux
97-
python: "pypy-5.3.1"
106+
python: "pypy3.5-5.8.0"
107+
- os: linux
108+
python: "pypy2.7-5.8.0"
109+
- os: linux
110+
python: "pypy3.5-6.0"
98111
- os: linux
99112
python: "nightly" # currently points to 3.7-dev
100113
env: TRAVIS_PYTHON_VERSION="3.7-dev"
@@ -153,27 +166,28 @@ before_script:
153166
script:
154167
- make clean ;
155168
- if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP make test" ; else make test || exit $? ; fi ;
156-
- if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP codecov" ; else codecov || exit $? ; fi ;
169+
- if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov || exit $? ; fi ;
157170
- cp -vf .coverage ".coverall.Lasting.45678.12345" 2>/dev/null || true
158171
- make clean || exit $? ;
159-
- make test-tox || exit $? ;
172+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP make test-tox" ; else make test-tox || exit $? ; fi ;
160173
- make clean ;
161174
- mv -vf ".coverall.Lasting.45678.12345" .coverage 2>/dev/null || true
162175

163176
after_failure:
164-
- coverage combine 2>/dev/null || true
165-
- coverage xml 2>/dev/null || true
166-
- if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ;
167-
- codecov 2>/dev/null || true
177+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage" ; else coverage combine 2>/dev/null || true ; fi ;
178+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage xml" ; else coverage xml 2>/dev/null || true ; fi ;
179+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov 2>/dev/null || true ; fi ;
180+
- if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ;
181+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov 2>/dev/null || true ; fi ;
168182
- make clean 2>/dev/nul || true
169183

170184
after_success:
171-
- coverage combine || true
172-
- coverage xml || true
173-
- if [ $TRAVIS_OS_NAME == osx ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ;
174-
- codecov || true
185+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage" ; else coverage combine 2>/dev/null || true ; fi ;
186+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP coverage xml" ; else coverage xml 2>/dev/null || true ; fi ;
187+
- if [ $TRAVIS_OS_NAME == osx ] || [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP code climate" ; else ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || true ; fi ;
188+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else codecov || true ; fi ;
175189
- travis_retry python3 -m pip install python-coveralls || python3 -m pip install python-coveralls || true ;
176-
- coveralls 2>/dev/null || true
190+
- if [ $TRAVIS_PYTHON_VERSION == "3.2" ] ; then echo "SKIP codecov" ; else coveralls 2>/dev/null || true ; fi ;
177191
- travis_wait 35 curl --url "https://scan.coverity.com/download/linux64?token=${COVERTY_TOKEN}&project=reactive-firewall%2Fpython-repo" -o coverity_tool.tgz || true
178192
- travis_wait tar xzf coverity_tool.tgz || true
179193
- rm -fr cov-int || true

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ By default this template will assume that the Travis CI Service and Circle-CI Se
1313
[![Appveyor](https://ci.appveyor.com/api/projects/status/6gggp1wpbnnjokm4/branch/master?svg=true)](https://ci.appveyor.com/project/reactive-firewall/python-repo/branch/master)
1414
[![Python 3](https://pyup.io/repos/github/reactive-firewall/python-repo/python-3-shield.svg)](https://pyup.io/repos/github/reactive-firewall/PiAP-python-tools/)
1515
[![Updates](https://pyup.io/repos/github/reactive-firewall/python-repo/shield.svg)](https://pyup.io/repos/github/reactive-firewall/python-repo/)
16-
[![Dependency Status](https://gemnasium.com/badges/github.com/reactive-firewall/python-repo.svg)](https://gemnasium.com/github.com/reactive-firewall/python-repo)
17-
[![Dependency Status](https://www.versioneye.com/user/projects/59cc1dc1368b0831e6126dc6/badge.svg?style=flat-round)](https://www.versioneye.com/user/projects/59cc1dc1368b0831e6126dc6)
16+
![Size](https://img.shields.io/github/languages/code-size/reactive-firewall/python-repo.svg)
1817
[![Test Coverage](https://api.codeclimate.com/v1/badges/f76f4e7e2eae6bff9b6a/test_coverage)](https://codeclimate.com/github/reactive-firewall/python-repo/test_coverage)
1918
[![code coverage](https://codecov.io/gh/reactive-firewall/python-repo/branch/master/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/python-repo/branch/master/)
2019
[![Coverage Status](https://coveralls.io/repos/github/reactive-firewall/python-repo/badge.svg?branch=master)](https://coveralls.io/github/reactive-firewall/python-repo?branch=master)
@@ -25,10 +24,10 @@ By default this template will assume that the Travis CI Service and Circle-CI Se
2524
### Stable:
2625
[![status](https://travis-ci.org/reactive-firewall/python-repo.svg?branch=stable)](https://travis-ci.org/reactive-firewall/python-repo)
2726
[![CircleCI](https://circleci.com/gh/reactive-firewall/python-repo/tree/stable.svg?style=svg)](https://circleci.com/gh/reactive-firewall/python-repo/tree/stable)
27+
[![Appveyor](https://ci.appveyor.com/api/projects/status/6gggp1wpbnnjokm4/branch/stable?svg=true)](https://ci.appveyor.com/project/reactive-firewall/python-repo/branch/stable)
2828
[![code coverage](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/)
2929
[![code coverage](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/python-repo/branch/stable/)
3030
[![Coverage Status](https://coveralls.io/repos/github/reactive-firewall/python-repo/badge.svg?branch=stable)](https://coveralls.io/github/reactive-firewall/python-repo?branch=stable)
31-
[![Dependency Status](https://www.versioneye.com/user/projects/59cc1dce368b083214208a72/badge.svg?style=flat-round)](https://www.versioneye.com/user/projects/59cc1dce368b083214208a72)
3231

3332

3433
# How do I use this to create a new project repo?

pythonrepo/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Python Repo Template
44
# ..................................
5-
# Copyright (c) 2017, Kendrick Walls
5+
# Copyright (c) 2017-2018, Kendrick Walls
66
# ..................................
77
# Licensed under MIT (the "License");
88
# you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
1717
# limitations under the License.
1818

1919

20-
__version__ = """1.0.1"""
21-
"""This is version 1.0.1 of pythonrepo Template"""
20+
__version__ = """1.1.0"""
21+
"""This is version 1.1.0 of pythonrepo Template"""
2222

2323
try:
2424
import sys
@@ -38,10 +38,10 @@
3838
from . import pythonrepo as pythonrepo
3939
except Exception as importErr:
4040
del importErr
41-
import pythonrepo as pythonrepo
41+
import pythonrepo.pythonrepo as pythonrepo
4242

4343

44-
if __name__ in u'__main__':
44+
if __name__ in '__main__':
4545
if pythonrepo.__name__ is None:
4646
raise ImportError(str("Failed to open pythonrepo"))
4747
pythonrepo.main(sys.argv[1:])

pythonrepo/pythonrepo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ def parseArgs(arguments=None):
103103
return parser.parse_known_args(arguments)
104104

105105

106-
def useTool(tool, arguments=[None]):
106+
def useTool(tool, arguments=None):
107107
"""Handler for launching the functions."""
108+
if arguments is None:
109+
arguments = [None]
108110
if tool is None:
109111
return None
110112
if tool in TASK_OPTIONS.keys():

tests/profiling.py

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Python Repo Template
55
# ..................................
6-
# Copyright (c) 2017, Kendrick Walls
6+
# Copyright (c) 2017-2018, Kendrick Walls
77
# ..................................
88
# Licensed under MIT (the "License");
99
# you may not use this file except in compliance with the License.
@@ -31,38 +31,18 @@
3131

3232
try:
3333
import os
34-
if os.__name__ is None:
35-
raise NotImplementedError("OMG! We could not import the os. We're like in the matrix!")
36-
except Exception as err:
37-
raise ImportError(err)
38-
exit(3)
39-
40-
41-
try:
4234
import sys
43-
if sys.__name__ is None:
44-
raise NotImplementedError("OMG! We could not import the sys. We're like in the matrix!")
45-
except Exception as err:
46-
raise ImportError(err)
47-
exit(3)
48-
49-
50-
try:
5135
import time
52-
if time.__name__ is None:
53-
raise NotImplementedError("OMG! We could not import time. We're like in the speed-force!")
54-
except Exception as err:
55-
raise ImportError(err)
56-
exit(3)
57-
58-
59-
try:
6036
import cProfile
61-
if cProfile.__name__ is None:
62-
raise NotImplementedError("OMG! We could not import cProfile. ABORT!")
37+
for keyModule in [os, sys, time, cProfile]:
38+
if keyModule.__name__ is None:
39+
raise NotImplementedError(
40+
str("OMG! We could not import the {}!").format(
41+
str(keyModule)
42+
)
43+
)
6344
except Exception as err:
6445
raise ImportError(err)
65-
exit(3)
6646

6747

6848
try:
@@ -106,7 +86,6 @@ def __enter__(self):
10686

10787
def __exit__(self, type, value, traceback):
10888
self.checkpoint(str("finished"))
109-
pass
11089

11190

11291
def do_time_profile(func, timer_name="time_profile"):
@@ -143,7 +122,10 @@ def profiled_func(*args, **kwargs):
143122
try: # noqa
144123
from line_profiler import LineProfiler
145124

146-
def do_profile(follow=[]):
125+
def do_profile(follow=None):
126+
if follow is None:
127+
follow = []
128+
147129
def inner(func):
148130
def profiled_func(*args, **kwargs):
149131
try:
@@ -159,8 +141,11 @@ def profiled_func(*args, **kwargs):
159141
return inner
160142

161143
except ImportError:
162-
def do_profile(follow=[]):
144+
def do_profile(follow=None):
163145
"Helpful if you accidentally leave in production!"
146+
if follow is None:
147+
follow = []
148+
164149
def inner(func):
165150
def nothing(*args, **kwargs):
166151
return func(*args, **kwargs)
@@ -173,10 +158,11 @@ def main(argv=None):
173158
raise NotImplementedError("CRITICAL - test profiling main() not implemented. yet?")
174159

175160

176-
if __name__ in u'__main__':
161+
if __name__ in '__main__':
162+
exitcode = 3
177163
try:
178-
exit(main(sys.argv[1:]))
179-
except Exception:
180-
exit(3)
164+
exitcode = main(sys.argv[1:])
165+
finally:
166+
exit(exitcode)
181167

182168

tests/test_usage.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import unittest
2222
import subprocess
2323
import sys
24-
import profiling as profiling
24+
import tests.profiling as profiling
2525

2626

2727
def getPythonCommand():
@@ -51,14 +51,15 @@ def getPythonCommand():
5151
return str(thepython)
5252

5353

54-
def checkPythonCommand(args=[None], stderr=None):
54+
def checkPythonCommand(args=None, stderr=None):
5555
"""Function for backend subprocess check_output command like testing with coverage support"""
5656
theOutput = None
5757
try:
5858
if args is None or args is [None]:
59+
args = [None]
5960
theOutput = subprocess.check_output(["exit 1 ; #"])
6061
else:
61-
if str("coverage ") in args[0]:
62+
if str("coverage ") in str(args[0]):
6263
if sys.__name__ is None:
6364
raise ImportError("Failed to import system. WTF?!!")
6465
if str("{} -m coverage ").format(str(sys.executable)) in str(args[0]):
@@ -85,20 +86,23 @@ def checkPythonCommand(args=[None], stderr=None):
8586

8687

8788
@profiling.do_cprofile
88-
def timePythonCommand(args=[None], stderr=None):
89+
def timePythonCommand(args=None, stderr=None):
8990
"""Function for backend subprocess check_output command
9091
with support for coverage and profiling."""
92+
if args is None:
93+
args = [None]
9194
return checkPythonCommand(args, stderr)
9295

9396

94-
def checkPythonErrors(args=[None], stderr=None):
97+
def checkPythonErrors(args=None, stderr=None):
9598
"""Function like checkPythonCommand, but with error passing."""
9699
theOutput = None
97100
try:
98101
if args is None or args is [None]:
102+
args = [None]
99103
theOutput = subprocess.check_output(["exit 1 ; #"])
100104
else:
101-
if str("coverage ") in args[0]:
105+
if str("coverage ") in str(args[0]):
102106
import sys
103107
if sys.__name__ is None:
104108
raise ImportError("Failed to import system. WTF?!!")

0 commit comments

Comments
 (0)