Skip to content

Commit

Permalink
Rename metavars, more skip tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
thebjorn committed Jul 13, 2019
1 parent c853683 commit 64e97ad
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 10 deletions.
17 changes: 9 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pydeps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
67 changes: 66 additions & 1 deletion tests/test_skip.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 64e97ad

Please sign in to comment.