Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Fix(#161): all testscases now pass #183

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tests:

flake8 --exclude=__init__.py,memory_profiler.py pycallgraph
flake8 --ignore=F403 test
flake8 examples
flake8 examples --exclude=all.py

doc:
cd docs/examples && ./generate.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ def main():
s2 = SubmoduleTwo()
s2.report()


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/graphviz/recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ def main():
for a in xrange(1, 10):
factorial(a)


if __name__ == '__main__':
main()
5 changes: 3 additions & 2 deletions examples/graphviz/regexp.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def main():
config = Config(include_stdlib=True)

with PyCallGraph(output=graphviz, config=config):
reo = compile()
reo = compile_regex()
match(reo)


def compile():
def compile_regex():
return re.compile('^[abetors]*$')


Expand All @@ -41,5 +41,6 @@ def words():
'abrasives',
]


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion pycallgraph/output/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def debug(self, text):
self.processor.config.log_debug(text)

@classmethod
def add_output_file(cls, subparser, defaults, help):
def add_output_file(cls, subparser, defaults, help): # noqa: A002
subparser.add_argument(
'-o', '--output-file', type=str, default=defaults.output_file,
help=help,
Expand Down
2 changes: 1 addition & 1 deletion pycallgraph/pycallgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, output=None, config=None):
def __enter__(self):
self.start()

def __exit__(self, type, value, traceback):
def __exit__(self, type, value, traceback): # noqa: A002
self.done()

def get_tracer_class(self):
Expand Down
1 change: 1 addition & 0 deletions pycallgraph/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,5 @@ def wrapper(*rest):

return wrapper


inspect.getmodule = simple_memoize(inspect.getmodule)
18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/usr/bin/env python

from os import path
from setuptools import setup
import sys

from setuptools import setup
from setuptools.command.test import test as TestCommand

import pycallgraph


# Only install the man page if the correct directory exists
# XXX: Commented because easy_install doesn't like it
#man_path = '/usr/share/man/man1/'
#if path.exists(man_path):
# data_files=[['/usr/share/man/man1/', ['man/pycallgraph.1']]]
#else:
# data_files=None
data_files = None

data_files=None

class PyTest(TestCommand):

Expand All @@ -30,6 +30,7 @@ def run_tests(self):
errno = pytest.main(self.test_args)
sys.exit(errno)


setup(
name='pycallgraph',
version=pycallgraph.__version__,
Expand All @@ -45,15 +46,15 @@ def run_tests(self):
use_2to3=True,

# TODO: Update download_url
download_url =
'http://pycallgraph.slowchop.com/files/download/pycallgraph-%s.tar.gz' % \
pycallgraph.__version__,
download_url=
'http://pycallgraph.slowchop.com/files/download/pycallgraph-%s.tar.gz' %
pycallgraph.__version__,

# Testing
tests_require=['pytest'],
cmdclass = {'test': PyTest},
cmdclass={'test': PyTest},

classifiers = [
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License (GPL)',
Expand All @@ -68,4 +69,3 @@ def run_tests(self):
'Topic :: Software Development :: Debuggers',
],
)

3 changes: 2 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pycallgraph import PyCallGraph, Config
import tempfile

from helpers import *
import pytest


@pytest.fixture(scope='module')
Expand Down
7 changes: 0 additions & 7 deletions test/helpers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# flake8: noqa
import time

import pytest

import fix_path
from pycallgraph import *
from pycallgraph.tracer import *
from pycallgraph.output import *


def wait_100ms():
time.sleep(0.1)
Expand Down
4 changes: 3 additions & 1 deletion test/test_color.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from helpers import *
from pycallgraph import ColorException, Color

import pytest


def test_bad_range():
Expand Down
2 changes: 1 addition & 1 deletion test/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helpers import *
from pycallgraph.config import Config


def test_init():
Expand Down
9 changes: 7 additions & 2 deletions test/test_gephi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from helpers import *
from calls import *
from pycallgraph import PyCallGraph
from pycallgraph.output.gephi import GephiOutput
import os

import pytest

from calls import one_nop


@pytest.fixture
Expand Down
9 changes: 7 additions & 2 deletions test/test_graphviz.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from helpers import *
from calls import *
from pycallgraph.output.graphviz import GraphvizOutput
from pycallgraph.pycallgraph import PyCallGraph
import os

import pytest

from calls import one_nop


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion test/test_output.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from helpers import *
from pycallgraph import Config
from pycallgraph.output import Output


def test_set_config():
Expand Down
5 changes: 4 additions & 1 deletion test/test_pycallgraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from helpers import *
from pycallgraph.exceptions import PyCallGraphException
from pycallgraph.tracer import AsyncronousTracer, SyncronousTracer

import pytest


def test_start_no_outputs(pycg):
Expand Down
2 changes: 0 additions & 2 deletions test/test_script.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import subprocess

from helpers import *


def execute(arguments):
command = 'PYTHONPATH=. scripts/pycallgraph ' + arguments
Expand Down
14 changes: 8 additions & 6 deletions test/test_trace_processor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from pycallgraph.tracer import TraceProcessor
import re
import sys

from helpers import *
import calls
from pycallgraph.tracer import TraceProcessor
import pytest

from pycallgraph import Config
from calls import one_nop, nop


@pytest.fixture
Expand All @@ -20,7 +22,7 @@ def test_empty(trace_processor):

def test_nop(trace_processor):
sys.settrace(trace_processor.process)
calls.nop()
nop()
sys.settrace(None)

assert trace_processor.call_dict == {
Expand All @@ -32,7 +34,7 @@ def test_nop(trace_processor):

def test_one_nop(trace_processor):
sys.settrace(trace_processor.process)
calls.one_nop()
one_nop()
sys.settrace(None)

assert trace_processor.call_dict == {
Expand All @@ -45,7 +47,7 @@ def stdlib_trace(trace_processor, include_stdlib):
trace_processor.config = Config(include_stdlib=include_stdlib)
sys.settrace(trace_processor.process)
re.match("asdf", "asdf")
calls.one_nop()
one_nop()
sys.settrace(None)
return trace_processor.call_dict

Expand Down
2 changes: 1 addition & 1 deletion test/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helpers import *
from pycallgraph.util import Util


def test_human_readable_biyte():
Expand Down