From 64e97ad9cef2a5ba42570db7a96815b48ee1c948 Mon Sep 17 00:00:00 2001 From: thebjorn Date: Sat, 13 Jul 2019 20:57:16 +0200 Subject: [PATCH] Rename metavars, more skip tests. --- README.rst | 17 ++++++------ pydeps/cli.py | 2 +- tests/test_skip.py | 67 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 1ec31b5..35abd3d 100644 --- a/README.rst +++ b/README.rst @@ -162,12 +162,13 @@ eg. the output from ``pydeps --show-deps ..`` looks like this:: Usage:: - usage: pydeps [-h] [--config FILE] [--no-config] [--version] [-L LOG] [-v] - [-o file] [-T FORMAT] [--display PROGRAM] [--noshow] - [--show-deps] [--show-raw-deps] [--show-dot] [--nodot] - [--show-cycles] [--debug] [--noise-level INT] [--max-bacon INT] - [--pylib] [--pylib-all] [--include-missing] - [-x FNAME [FNAME ...]] [--externals] [--reverse] + usage: pydeps [-h] [--debug] [--config FILE] [--no-config] [--version] + [-L LOG] [-v] [-o file] [-T FORMAT] [--display PROGRAM] + [--noshow] [--show-deps] [--show-raw-deps] [--show-dot] + [--nodot] [--no-output] [--show-cycles] [--debug-mf INT] + [--noise-level INT] [--max-bacon INT] [--pylib] [--pylib-all] + [--include-missing] [-x PATTERN [PATTERN ...]] + [-xx MODULE [MODULE ...]] [--externals] [--reverse] fname positional arguments: @@ -201,8 +202,8 @@ optional arguments: (default=2, 0 -> infinite) --pylib include python std lib modules --pylib-all include python all std lib modules (incl. C modules) - --x FNAME, --exclude FNAME input files to skip (multiple file names can be provided) - --xx FNAME, --exclude-exact FNAME same as --exclude, except requires the full match. `-xx foo.bar` will exclude foo.bar, but not foo.bar.blob + --x PATTERN, --exclude PATTERN input files to skip (e.g. `foo.*`), multiple patterns can be provided + --xx MODULE, --exclude-exact MODULE same as --exclude, except requires the full match. `-xx foo.bar` will exclude foo.bar, but not foo.bar.blob --externals create list of direct external dependencies --reverse draw arrows to (instead of from) imported modules diff --git a/pydeps/cli.py b/pydeps/cli.py index 39e50a7..2de2c18 100644 --- a/pydeps/cli.py +++ b/pydeps/cli.py @@ -121,7 +121,7 @@ def parse_args(argv=()): args.add('--pylib-all', action='store_true', help="include python all std lib modules (incl. C modules)") args.add('--include-missing', action='store_true', help="include modules that are not installed (or can't be found on sys.path)") args.add('-x', '--exclude', default=[], nargs="+", metavar="PATTERN", help="input files to skip (e.g. `foo.*`), multiple file names can be provided") - args.add('-xx', '--exclude-exact', default=[], nargs="+", metavar="MODULE", help="input files to skip (exact match, e.g. `pydeps.__main__`), multiple file names can be provided") + args.add('-xx', '--exclude-exact', default=[], nargs="+", metavar="MODULE", help="same as --exclude, except requires the full match. `-xx foo.bar` will exclude foo.bar, but not foo.bar.blob") args.add('--externals', action='store_true', help='create list of direct external dependencies') args.add('--reverse', action='store_true', help="draw arrows to (instead of from) imported modules") diff --git a/tests/test_skip.py b/tests/test_skip.py index 6e7992c..a720d4f 100644 --- a/tests/test_skip.py +++ b/tests/test_skip.py @@ -1,9 +1,74 @@ # -*- coding: utf-8 -*- -import os +from __future__ import print_function from tests.filemaker import create_files from tests.simpledeps import simpledeps, depgrf +def test_no_skip(): + files = """ + relimp: + - __init__.py + - a.py: | + from . import b + - b.py: | + from . import c + - c.py + """ + with create_files(files) as workdir: + print("plain", simpledeps('relimp')) + assert simpledeps('relimp') == { + 'relimp.b -> relimp.a', + 'relimp.c -> relimp.b' + } + + +def test_skip_module_pattern(): + files = """ + relimp: + - __init__.py + - a.py: | + from . import b + - b.py: | + from . import c + - c.py + """ + with create_files(files) as workdir: + print("-x", simpledeps('relimp', '-x relimp.*')) + assert simpledeps('relimp', '-x relimp.*') == set() + + +# def test_skip_exact_pattern(): +# files = """ +# relimp: +# - __init__.py +# - a.py: | +# from . import b +# - b.py: | +# from . import c +# - c.py +# """ +# with create_files(files) as workdir: +# print('-xx', simpledeps('relimp', '-xx relimp.*')) +# assert simpledeps('relimp', '-xx relimp.*') != set() + + +def test_skip_exact(): + files = """ + relimp: + - __init__.py + - a.py: | + from . import b + - b.py: | + from . import c + - c.py + """ + with create_files(files) as workdir: + print('-xx', simpledeps('relimp', '-xx relimp.c')) + assert simpledeps('relimp', '-xx relimp.c') == { + 'relimp.b -> relimp.a' + } + + def test_skip_modules(): files = """ relimp: