Skip to content

Commit 69f3846

Browse files
committed
Merge branch 'release/1.5'
* release/1.5: (32 commits) bump version 1.5 updates README fixes coverage updates README minor updates add codecov to travis updates tox/travis config add globbing env and package version fixes typo in README update LICENSE fixes travis/tox config removes python 3.2 add 3.5 tests updates README update travis config set capture=no updates travis config fixes travis config updates and minor fixes - add appveyor CI fixes typo and docs fixes travis config ...
2 parents d546201 + 8011b24 commit 69f3846

File tree

13 files changed

+304
-62
lines changed

13 files changed

+304
-62
lines changed

.coveragerc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[run]
2+
branch = True
3+
source = pytest_echo
4+
5+
omit =
6+
7+
[report]
8+
# Regexes for lines to exclude from consideration
9+
exclude_lines =
10+
pragma: no cover
11+
12+
ignore_errors = False
13+
14+
[html]
15+
directory = ~build/coverage

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
.cache
33
.tox
44
dist
5-
*.egg-info
5+
pytest_echo.egg-info
66
*.pyc
77
__pycache__
88
docs/_build
9+
.coverage
10+
~build

.travis.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
language: python
2+
sudo: false
23

34
python:
45
- "2.6"
56
- "2.7"
6-
- "3.2"
77
- "3.3"
88
- "3.4"
9+
- "3.5"
10+
- "3.6"
911
- "pypy"
1012

1113
install:
12-
- "pip install -e ."
13-
- "pip install pytest --use-mirrors"
14-
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then travis_retry pip install 'django<1.5'; fi
15-
- if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then travis_retry pip install 'django>=1.6'; fi
14+
- pip install .
15+
- pip install tox coverage codecov
16+
- "TOX_ENV=${TRAVIS_PYTHON_VERSION/[0-9].[0-9]/py${TRAVIS_PYTHON_VERSION/.}}"
1617

1718

1819
branches:
1920
only:
21+
- master
2022
- develop
23+
- feature/travis
2124

22-
script:
23-
py.test
25+
26+
before_success:
27+
- coverage erase
28+
29+
30+
after_success:
31+
- coverage combine
32+
- codecov
33+
34+
script: tox -e $TOX_ENV

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.5
2+
---
3+
* add support for 'globbing' package version and enviromnent variables
4+
* add python 3.5 and 3.6 support
5+
16
1.4
27
---
38
* fixes typo in documentation

LICENSE

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2015-2016 Stefano Apostolico
4+
15
Permission is hereby granted, free of charge, to any person obtaining a copy
26
of this software and associated documentation files (the "Software"), to deal
37
in the Software without restriction, including without limitation the rights
48
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
59
copies of the Software, and to permit persons to whom the Software is
610
furnished to do so, subject to the following conditions:
711

8-
The above copyright notice and this permission notice shall be included in all
9-
copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
1014

1115
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1216
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1317
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1418
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1519
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17-
SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.rst

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
pytest-echo
22
===========
33

4+
.. image:: https://badge.fury.io/py/pytest-echo.svg
5+
:target: http://badge.fury.io/py/pytest-echo
6+
:alt: PyPI package
47

5-
.. image:: https://pypip.in/v/pytest-echo/badge.png
6-
:target: https://crate.io/packages/pytest-echo/
78

8-
.. image:: https://pypip.in/d/pytest-echo/badge.png
9-
:target: https://crate.io/packages/pytest-echo/
10-
11-
12-
Print environment variables, package version and generic attributes.
13-
14-
Useful in the continuous integration to dump test configuration/environment.
9+
Print environment variables, package version and generic attributes,
10+
as they are at the begining of the test.
1511

12+
Useful in the continuous integration to dump test
13+
configuration/environment and or to check is attributes are properly set
14+
(ie. you change environment with `os.environ`)
1615

1716
Install
1817
-------
@@ -70,8 +69,8 @@ Dump attributes
7069
DEBUG: False
7170
plugins: echo, pydev, cov, cache, django
7271
73-
.. warning:: Be careful when use ``--echo-attr``. It load any module in the path and this will
74-
execute any module's level code
72+
.. warning:: Be careful when use ``--echo-attr``. It loads any module in the path and this will
73+
execute any module level code
7574
If you try to dump a property, related ``getter`` will be executed.
7675

7776
.. note:: You cannot dump callable result.
@@ -93,7 +92,7 @@ Example of use in a django project:
9392
--echo-env DBENGINE
9493
--echo-version django
9594
--echo-version pip
96-
--echo-version pytest_echo
95+
--echo-version pytest-echo
9796
--echo-attr django.conf.settings.DATABASES.default.ENGINE
9897
9998
@@ -119,15 +118,64 @@ Example of use in a django project:
119118
.............
120119
14 passed in 4.95 seconds
121120
121+
122+
Globbing
123+
~~~~~~~~
124+
125+
Starting from version 1.5, is possible to glob packages version and environment variables,
126+
as:
127+
128+
.. code-block:: sh
129+
130+
$ py.test --echo-version=pytest-* --echo-env=VIRTUAL*
131+
132+
or
133+
134+
.. code-block:: inifile
135+
136+
[pytest]
137+
addopts = -vvv
138+
--echo-env VIRTUAL*
139+
--echo-version pytest-*
140+
141+
142+
143+
122144
Links
123145
~~~~~
124146

125-
+--------------------+----------------+--------------+----------------+
126-
| Project home page: |https://github.com/saxix/pytest-echo |
127-
+--------------------+---------------+--------------------------------+
128-
| Issue tracker: |https://github.com/saxix/pytest-echo/issues?sort|
129-
+--------------------+---------------+--------------------------------+
130-
| Download: |http://pypi.python.org/pypi/pytest-echo/ |
131-
+--------------------+---------------+--------------------------------+
132-
| Documentation: |https://pytest-echo.readthedocs.org/en/latest/ |
133-
+--------------------+---------------+--------------+-----------------+
147+
+--------------------+----------------+--------------+-----------------+
148+
| Stable | |master-build| | |master-cov| | |master-doc| |
149+
+--------------------+----------------+--------------+-----------------+
150+
| Development | |dev-build| | |dev-cov| | |dev-doc| |
151+
+--------------------+-------------------------------------------------+
152+
| Project home page: |https://github.com/saxix/pytest-echo |
153+
+--------------------+-------------------------------------------------+
154+
| Issue tracker: |https://github.com/saxix/pytest-echo/issues?sort |
155+
+--------------------+-------------------------------------------------+
156+
| CI: |https://travis-ci.org/saxix/pytest-echo |
157+
+--------------------+-------------------------------------------------+
158+
| Download: |http://pypi.python.org/pypi/pytest-echo/ |
159+
+--------------------+-------------------------------------------------+
160+
| Documentation: |https://pytest-echo.readthedocs.org/en/latest/ |
161+
+--------------------+-------------------------------------------------+
162+
163+
164+
.. |master-build| image:: https://secure.travis-ci.org/saxix/pytest-echo.png?branch=master
165+
:target: http://travis-ci.org/saxix/pytest-echo/
166+
167+
.. |master-cov| image:: https://codecov.io/gh/saxix/pytest-echo/branch/master/graph/badge.svg
168+
:target: https://codecov.io/gh/saxix/pytest-echo
169+
170+
.. |master-doc| image:: https://readthedocs.org/projects/pytest-echo/badge/?version=stable
171+
:target: http://pytest-echo.readthedocs.io/en/stable/
172+
173+
.. |dev-build| image:: https://secure.travis-ci.org/saxix/pytest-echo.png?branch=develop
174+
:target: http://travis-ci.org/saxix/pytest-echo/
175+
176+
.. |dev-cov| image:: https://codecov.io/gh/saxix/pytest-echo/branch/develop/graph/badge.svg
177+
:target: https://codecov.io/gh/saxix/pytest-echo
178+
179+
.. |dev-doc| image:: https://readthedocs.org/projects/pytest-echo/badge/?version=latest
180+
:target: http://pytest-echo.readthedocs.io/en/latest/
181+

appveyor.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# What Python version is installed where:
2+
# http://www.appveyor.com/docs/installed-software#python
3+
4+
environment:
5+
matrix:
6+
- PYTHON: "C:\\Python27"
7+
TOX_ENV: "py27"
8+
9+
- PYTHON: "C:\\Python33"
10+
TOX_ENV: "py33"
11+
12+
- PYTHON: "C:\\Python34"
13+
TOX_ENV: "py34"
14+
15+
- PYTHON: "C:\\Python35"
16+
TOX_ENV: "py35"
17+
18+
19+
init:
20+
- "%PYTHON%/python -V"
21+
- "%PYTHON%/python -c \"import struct;print( 8 * struct.calcsize(\'P\'))\""
22+
23+
install:
24+
- "%PYTHON%/Scripts/easy_install -U pip"
25+
- "%PYTHON%/Scripts/pip install tox"
26+
- "%PYTHON%/Scripts/pip install wheel"
27+
28+
build: false # Not a C# project, build stuff at the test step instead.
29+
30+
test_script:
31+
- "%PYTHON%/Scripts/tox -e %TOX_ENV%"
32+
33+
after_test:
34+
- "%PYTHON%/python setup.py bdist_wheel"
35+
- ps: "ls dist"
36+
37+
artifacts:
38+
- path: dist\*
39+
40+
#on_success:
41+
# - TODO: upload the content of dist/*.whl to a public wheelhouse

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
contain the root `toctree` directive.
55
66
Welcome to pytest-echo's documentation!
7-
========================================
7+
=======================================
88

99
Contents:
1010

pytest_echo.py

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# -*- coding: utf-8 -*-
2+
import fnmatch
23
import os
34
from pprint import pformat
45

6+
import pip
7+
from pkg_resources import DistributionNotFound
58

6-
__version__ = '1.4'
7-
8-
9-
class RetrieveException(Exception):
10-
pass
9+
__version__ = '1.5'
1110

1211

1312
def get_attr(obj, attr, default='NOT FOUND'):
1413
"""Recursive get object's attribute. May use dot notation.
1514
16-
>>> class C(object): pass
15+
>>> class C(object):
16+
... pass
1717
>>> a = C()
1818
>>> a.b = C()
1919
>>> a.b.c = 4
@@ -44,7 +44,7 @@ def get_attr(obj, attr, default='NOT FOUND'):
4444
return obj[attr]
4545
else:
4646
return default
47-
except Exception as e:
47+
except Exception as e: # pragma: no cover
4848
return str(e)
4949
else:
5050
L = attr.split('.')
@@ -67,6 +67,8 @@ def get_module_attribute(path):
6767
<type 'dict'>
6868
>>> print get_module_attribute('os.path.curdir')
6969
'.'
70+
>>> print get_module_attribute('wrong')
71+
('Unable to load %s', 'wrong')
7072
"""
7173
parts = path.split('.')
7274
parent = ""
@@ -88,12 +90,34 @@ def get_module_attribute(path):
8890
return str(e)
8991

9092

93+
def get_env(var_name):
94+
if '*' in var_name:
95+
targets = [(key, value)
96+
for key, value in os.environ.items()
97+
if fnmatch.fnmatch(key, var_name)]
98+
else:
99+
targets = [(var_name, os.environ.get(var_name, "<not set>"))]
100+
101+
return targets
102+
103+
104+
def get_version(package_name):
105+
if '*' in package_name:
106+
targets = [(i.key, i.version)
107+
for i in pip.get_installed_distributions()
108+
if fnmatch.fnmatch(i.key, package_name)]
109+
else:
110+
targets = [(package_name, _get_version(package_name))]
111+
112+
return targets
113+
114+
91115
def _get_version(package_name):
92116
try:
93117
import pkg_resources
94118

95119
return pkg_resources.require(package_name)[0].version
96-
except:
120+
except (ImportError, AttributeError, TypeError, DistributionNotFound):
97121
pass
98122

99123
try:
@@ -113,12 +137,20 @@ def pytest_report_header(config):
113137
ret = []
114138
if config.option.echo_envs:
115139
ret.append("Environment:")
116-
ret.append("\n".join([" %s: %s" % (k, os.environ.get(k, "<not set>"))
117-
for k in config.option.echo_envs]))
140+
data = []
141+
for k in config.option.echo_envs:
142+
data.extend(get_env(k))
143+
ret.append("\n".join([" %s: %s" % (k, v)
144+
for k, v in sorted(data)]))
145+
118146
if config.option.echo_versions:
119147
ret.append("Package version:")
120-
ret.append("\n".join([" %s: %s" % (k, _get_version(k))
121-
for k in config.option.echo_versions]))
148+
data = []
149+
for k in config.option.echo_versions:
150+
data.extend(get_version(k))
151+
ret.append("\n".join([" %s: %s" % (k, v)
152+
for k, v in sorted(data)]))
153+
122154
if config.option.echo_attribues:
123155
ret.append("Inspections:")
124156
ret.append("\n".join([" %s: %s" % (k, get_module_attribute(k))

0 commit comments

Comments
 (0)