Skip to content

Commit 70b4b13

Browse files
committed
updates README
1 parent 533426b commit 70b4b13

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ Dump package version
5353
pytest_echo: 0.1
5454
plugins: echo, pydev, cov, cache, django
5555
56+
.. warning:: The first attempt to retrieve the version is done via setuptools
57+
if it fails, the module is imported (``__import__(package)``) to retrieve the version reading
58+
``get_version``, ``__version__``, ``VERSION``, ``version`` so any module
59+
level code is executed. This should be not an issue as no problematic code
60+
should be present in the first level of the package
5661

5762
Dump attributes
5863
~~~~~~~~~~~~~~~

pytest_echo.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,18 @@ def get_module_attribute(path):
7272
parent = ""
7373
pkg = None
7474
try:
75-
for i, el in enumerate(parts):
75+
for i, part in enumerate(parts):
7676
try:
7777
if parent:
78-
a = "%s.%s" % (parent, parts[i])
78+
module_name = "%s.%s" % (parent, parts[i])
7979
else:
80-
a = parts[i]
81-
pkg = __import__(a, fromlist=[parent])
82-
parent = a
80+
module_name = parts[i]
81+
pkg = __import__(module_name, fromlist=[parent])
82+
parent = module_name
8383
except ImportError:
84-
if hasattr(pkg, el):
84+
if hasattr(pkg, part):
8585
return pformat(get_attr(pkg, ".".join(parts[i:])))
86+
raise Exception('Unable to load %s', path)
8687
except Exception as e:
8788
return str(e)
8889

0 commit comments

Comments
 (0)