Commit 48f4ff31 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 1.8.1

parent cbbf7cd4
......@@ -4,9 +4,14 @@ python:
- 2.7
- 3.2
- 3.3
- 3.4
install:
- sudo apt-get install graphviz
- pip install coverage coveralls
- pip install -e .
script:
- python tests.py
- coverage run --source=objgraph tests.py
after_success:
- coveralls
notifications:
email: false
......@@ -3,6 +3,16 @@ Changes
.. currentmodule:: objgraph
1.8.1 (2014-05-15)
------------------
- Do not expect file objects to have an ``encoding`` attribute. Makes objgraph
compatible with Eventlet's monkey-patching.
Fixes `issue 6 <https://github.com/mgedmin/objgraph/pull/6>`_. Contributed
by Jakub Stasiak.
1.8.0 (2014-02-13)
------------------
......
......@@ -58,7 +58,7 @@ preview-pypi-description:
.PHONY: coverage
coverage:
PYTHONPATH=.:$$PYTHONPATH coverage run tests.py
PYTHONPATH=.:$$PYTHONPATH coverage run --source=objgraph tests.py
coverage report
.PHONY: dist
......
Metadata-Version: 1.1
Name: objgraph
Version: 1.8.0
Version: 1.8.1
Summary: Draws Python object reference graphs with graphviz
Home-page: http://mg.pov.lt/objgraph/
Author: Marius Gedminas
......@@ -12,6 +12,10 @@ Description: Python Object Graphs
.. image:: https://travis-ci.org/mgedmin/objgraph.png?branch=master
:target: https://travis-ci.org/mgedmin/objgraph
.. image:: https://coveralls.io/repos/mgedmin/objgraph/badge.png?branch=master
:target: https://coveralls.io/r/mgedmin/objgraph?branch=master
``objgraph`` is a module that lets you visually explore Python object graphs.
You'll need `graphviz <http://www.graphviz.org/>`_ if you want to draw
......@@ -60,6 +64,7 @@ Description: Python Object Graphs
Report bugs at https://github.com/mgedmin/objgraph/issues.
If you want to leave a tip, see https://www.gittip.com/mgedmin/
......@@ -68,6 +73,16 @@ Description: Python Object Graphs
1.8.1 (2014-05-15)
------------------
- Do not expect file objects to have an ``encoding`` attribute. Makes objgraph
compatible with Eventlet's monkey-patching.
Fixes `issue 6 <https://github.com/mgedmin/objgraph/pull/6>`_. Contributed
by Jakub Stasiak.
1.8.0 (2014-02-13)
------------------
......@@ -272,3 +287,4 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
......@@ -4,6 +4,10 @@ Python Object Graphs
.. image:: https://travis-ci.org/mgedmin/objgraph.png?branch=master
:target: https://travis-ci.org/mgedmin/objgraph
.. image:: https://coveralls.io/repos/mgedmin/objgraph/badge.png?branch=master
:target: https://coveralls.io/r/mgedmin/objgraph?branch=master
``objgraph`` is a module that lets you visually explore Python object graphs.
You'll need `graphviz <http://www.graphviz.org/>`_ if you want to draw
......@@ -52,3 +56,4 @@ To check it out, use ``git clone https://github.com/mgedmin/objgraph``.
Report bugs at https://github.com/mgedmin/objgraph/issues.
If you want to leave a tip, see https://www.gittip.com/mgedmin/
Metadata-Version: 1.1
Name: objgraph
Version: 1.8.0
Version: 1.8.1
Summary: Draws Python object reference graphs with graphviz
Home-page: http://mg.pov.lt/objgraph/
Author: Marius Gedminas
......@@ -12,6 +12,10 @@ Description: Python Object Graphs
.. image:: https://travis-ci.org/mgedmin/objgraph.png?branch=master
:target: https://travis-ci.org/mgedmin/objgraph
.. image:: https://coveralls.io/repos/mgedmin/objgraph/badge.png?branch=master
:target: https://coveralls.io/r/mgedmin/objgraph?branch=master
``objgraph`` is a module that lets you visually explore Python object graphs.
You'll need `graphviz <http://www.graphviz.org/>`_ if you want to draw
......@@ -60,6 +64,7 @@ Description: Python Object Graphs
Report bugs at https://github.com/mgedmin/objgraph/issues.
If you want to leave a tip, see https://www.gittip.com/mgedmin/
......@@ -68,6 +73,16 @@ Description: Python Object Graphs
1.8.1 (2014-05-15)
------------------
- Do not expect file objects to have an ``encoding`` attribute. Makes objgraph
compatible with Eventlet's monkey-patching.
Fixes `issue 6 <https://github.com/mgedmin/objgraph/pull/6>`_. Contributed
by Jakub Stasiak.
1.8.0 (2014-02-13)
------------------
......@@ -272,3 +287,4 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
......@@ -29,8 +29,8 @@ Released under the MIT licence.
__author__ = "Marius Gedminas (marius@gedmin.as)"
__copyright__ = "Copyright (c) 2008-2014 Marius Gedminas"
__license__ = "MIT"
__version__ = "1.8.0"
__date__ = "2014-02-13"
__version__ = "1.8.1"
__date__ = "2014-05-15"
import codecs
......@@ -588,7 +588,7 @@ def show_graph(objs, edge_func, swap_source_target,
fd, dot_filename = tempfile.mkstemp(prefix='objgraph-',
suffix='.dot', text=True)
f = os.fdopen(fd, "w")
if f.encoding:
if getattr(f, 'encoding', None):
# Python 3 will wrap the file in the user's preferred encoding
# Re-wrap it for utf-8
import io
......@@ -604,7 +604,9 @@ def show_graph(objs, edge_func, swap_source_target,
ignore.add(id(depth))
ignore.add(id(ignore))
ignore.add(id(sys._getframe())) # this function
ignore.add(id(sys._getframe().f_locals))
ignore.add(id(sys._getframe(1))) # show_refs/show_backrefs, most likely
ignore.add(id(sys._getframe(1).f_locals))
for obj in objs:
f.write(' %s[fontcolor=red];\n' % (obj_node_id(obj)))
depth[id(obj)] = 0
......@@ -764,7 +766,7 @@ def short_repr(obj):
return obj.__func__.__name__ + ' (bound)'
else:
return obj.__func__.__name__
except AttributeError:
except AttributeError: # pragma: nocover
# Python < 2.6 compatibility
if obj.im_self is not None:
return obj.im_func.__name__ + ' (bound)'
......@@ -805,7 +807,7 @@ def edge_label(source, target, shortnames=True):
return ' [label="__self__",weight=10]'
if target is source.__func__:
return ' [label="__func__",weight=10]'
except AttributeError:
except AttributeError: # pragma: nocover
# Python < 2.6 compatibility
if target is source.im_self:
return ' [label="im_self",weight=10]'
......
......@@ -98,6 +98,7 @@ setup(name='objgraph',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
],
py_modules=['objgraph'],
**setuptools_options)
#!/usr/bin/python
import doctest
import gc
import glob
import os
import re
......@@ -31,6 +32,14 @@ class IgnoreNodeCountChecker(RandomOutputChecker):
return RandomOutputChecker.check_output(self, want, got, optionflags)
def skipIf(condition, reason):
def wrapper(fn):
if condition:
fn.__doc__ = 'Skipped because %s' % reason
return fn
return wrapper
def setUp(test):
test.tmpdir = tempfile.mkdtemp(prefix='test-objgraph-')
test.prevdir = os.getcwd()
......@@ -65,7 +74,7 @@ def doctest_setup_py_works():
>>> orig_argv = sys.argv
>>> sys.argv = ['setup.py', '--description']
>>> import setup
>>> import setup # noqa
Draws Python object reference graphs with graphviz
>>> sys.argv = orig_argv
......@@ -73,6 +82,152 @@ def doctest_setup_py_works():
"""
def doctest_count_long_type_names():
"""Test for count
>>> _ = gc.collect()
>>> x = type('MyClass', (), {'__module__': 'mymodule'})()
>>> y = type('MyClass', (), {'__module__': 'other'})()
>>> from objgraph import count
>>> count('MyClass')
2
>>> count('mymodule.MyClass')
1
"""
def doctest_typestats_long_type_names():
"""Test for typestats
>>> _ = gc.collect()
>>> x = type('MyClass', (), {'__module__': 'mymodule'})()
>>> from objgraph import typestats
>>> stats = typestats(shortnames=False)
>>> stats['mymodule.MyClass']
1
"""
def doctest_by_type_long_type_names():
"""Test for by_type
>>> x = type('MyClass', (), {'__module__': 'mymodule'})()
>>> from objgraph import by_type
>>> by_type('mymodule.MyClass') == [x]
True
"""
def doctest_find_chain_no_chain():
"""Test for find_chain
>>> from objgraph import find_chain
>>> a = object()
>>> find_chain(a, lambda x: False, gc.get_referrers) == [a]
True
"""
def doctest_obj_label_long_type_names():
r"""Test for obj_label
>>> x = type('MyClass', (), {'__module__': 'mymodule'})()
>>> from objgraph import obj_label
>>> obj_label(x, shortnames=False) # doctest: +ELLIPSIS
'mymodule.MyClass\\n<mymodule.MyClass object at ...'
"""
def doctest_long_typename_with_no_module():
r"""Test for long_typename
>>> x = type('MyClass', (), {'__module__': None})()
>>> from objgraph import long_typename
>>> long_typename(x)
'MyClass'
"""
def doctest_safe_repr_unsafe():
r"""Test for long_typename
>>> class MyClass(object):
... def __repr__(self):
... return 1/0
>>> x = MyClass()
>>> from objgraph import safe_repr
>>> safe_repr(x)
'(unrepresentable)'
"""
@skipIf(sys.version_info[0] > 2, "Python 3 has no unbound methods")
def doctest_short_repr_unbound_method():
r"""Test for long_typename
>>> class MyClass(object):
... def a_method(self):
... pass
>>> from objgraph import short_repr
>>> short_repr(MyClass.a_method)
'a_method'
"""
def doctest_gradient_empty():
"""Test for gradient
>>> from objgraph import gradient
>>> gradient((0.1, 0.2, 0.3), (0.2, 0.3, 0.4), 0, 0) == (0.1, 0.2, 0.3)
True
"""
@skipIf(sys.version_info[0] > 2, "Python 3 has no unbound methods")
@skipIf(sys.version_info[:2] < (2, 6), "Python 2.5 and older has no __func__")
def doctest_edge_label_unbound_method():
r"""Test for edge_label
>>> class MyClass(object):
... def a_method(self):
... pass
>>> from objgraph import edge_label
>>> edge_label(MyClass.a_method, MyClass.a_method.__func__)
' [label="__func__",weight=10]'
"""
def doctest_edge_label_long_type_names():
r"""Test for edge_label
>>> x = type('MyClass', (), {'__module__': 'mymodule'})()
>>> d = {x: 1}
>>> from objgraph import edge_label
>>> edge_label(d, 1, shortnames=False) # doctest: +ELLIPSIS
' [label="mymodule.MyClass\\n<mymodule.MyClass object at ..."]'
"""
def test_suite():
doctests = find_doctests()
return unittest.TestSuite([
......
[tox]
envlist = py26, py27, py32, py33
envlist = py26, py27, py32, py33, py34
[testenv]
commands = python tests.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment