Commit Graph

62 Commits

Author SHA1 Message Date
Vineet Naik c26603865d Implement 'ReversedPackageDAG.reverse' method
While this method is not being used in the script, it's been added for
completeness and to ensure that the APIs of all the classes involved
are clean.

Also, the 'DistPackage.as_required_by' method has been renamed to
'DistPackage.as_parent_of' for clarity.

Tests have been added and modified.
2020-04-14 19:15:52 +05:30
Vineet Naik 8766baa89a Refactored code to correct nomenclature and remove redundant code
- 'Tree' was used for class representing a direct acyclic
graph (DAG). It has now been appropriately renamed to 'PackageDAG'

- The 'ReverseTree' has been renamed to 'ReversedPackageDAG'

- The optional arg 'base' in the constructor and the instance
attribute havee been removed as they are nowhere being used

- Local variables are renamed, comments are modified and tests are
updated to reflect the above changes
2020-04-14 19:14:49 +05:30
Vineet Naik 917c880eeb Fix the behaviour of --reverse and --packages options together
The Tree class is completely agnostic of any notion of a dependency
tree. So it's filter and reverse methods purely work on the given
datastructure which is a map. So the combination of '--reverse' and
'--packages' options require the reverse method to be called before
filter. If done the other way, when reverse is called, it will have
only partial tree resulting in incorrect behaviour in the context of
this script.

Added documentation on the tree class and it's methods accordingly.
2020-04-12 13:27:59 +05:30
Vineet Naik ec1ee96963 Write new style integration tests
The earlier approach for integration tests was unreliable as it used
pickled objects from virtualenvs, which didn't work with all the pip
internal code and would often require tests to be fixed.

In this new approach, a combination of bash and python scripts drive
the tests. Test virtualenvs are setup on demand with support for
varying python and pip versions. As a result, the test
environment (python 3.6) can be completely different from the test
environment ie. the env in which pipdeptree is tested.

TODO: Get the new approach working with travis and remove old
integration tests.
2020-04-12 11:40:33 +05:30
Vineet Naik 1cb347c35b Check for conflicts in 'show_only' and 'exclude' after handling case
Earlier, in the Tree.filter method, we were checking for conflicts in
'show_only' and 'exclude' sets before normalizing all values to lower
case as a result of which it would miss values that were in both the
sets but in different cases.

This is now fixed by checking for conflicts after normalizing all the
values in both sets to lowercase first.
2019-10-27 16:07:52 +05:30
Vineet Naik 906e05147b Define Tree and ReverseTree classes representing dependency tree 2019-07-17 00:33:33 +05:30
Vineet Naik 4b74f7b4fe Rename 'test_pipdeptree.py' to 'test_integration.py'
So that a new 'test_pipdeptree.py' can be added for unit tests (with
mocking etc.).

Integration test suite will still be run during 'make test' but the
state of the test suite is pretty bad at present. In future, we might
replace it with a complete approach for easy maintenance.
2019-07-13 13:28:22 +05:30
Vineet Naik 51af7dd8d2 Fix pip._internal import in tests
Missed fixing the import of 'get_installed_distributions' in tests in
the earlier commit.

Also fixed indentation
2018-10-08 19:29:51 +05:30
Vineet Naik d5c3ce7bf5 Update test setup dependencies
The dependencies in test setup were old and in spite of the versions
being pinned, the test results were not consistent locally and
travis.

Note: This is an attempted fix (to be verified only after tests are
run on travis)
2018-07-01 19:17:16 +05:30
ciarancourtney d4bc9f487c tests: render_tree() expects exclude arg to be set, not list 2018-05-01 19:36:47 +01:00
ciarancourtney 1a15137510 restore arg-less main(), abstart args to _get_args() and monkeypatch in tests 2018-05-01 19:29:13 +01:00
ciarancourtney 1bcd65dc3a Using --packages and --exclude together is fine as long as they are distinct
* pass args into main() to make testing easier
2018-04-22 11:39:22 +01:00
ciarancourtney eb886d9a2f Add test for --exclude and --reverse 2018-04-15 21:47:20 +01:00
ciarancourtney 6910831af2 Remove wheel from tests (auto-updates self) 2018-04-15 21:47:20 +01:00
ciarancourtney d22cffb19f upgrade gnureadline 6.3.3 > 6.3.8 to avoid install issues (has wheels for py27 > py36) 2018-04-15 21:47:20 +01:00
ciarancourtney 9f0e439226 [closes #69] Add '--exclude' arg to exclude CSV list of packages and children from output 2018-04-15 21:47:20 +01:00
Vineet Naik e0cedb8ed0 Comment out flaky tests 2018-04-15 11:58:51 +05:30
Vineet Naik f32114130a Fix tests for render_json_tree
For easier debugging in case of failure
2018-04-15 10:50:40 +05:30
Vineet Naik 3520b6749d Fix tests for render_json_tree
Packages such as 'pip', 'pipdeptree', 'setuptools' and 'wheel' are
implicitly installed during test setup and hence ignored when
comparing output.
2018-04-15 10:35:00 +05:30
M. Dudley 9c6031cdc7 Fixed pip import to accomodate refactor in pip 10.0 2018-04-03 10:29:09 -04:00
Haiko Schol 932ed4b5c3 Update psycopg2 version in one of the test environments
psycopg2 2.5.2 fails to install with PostgreSQL 10+.
2018-02-21 19:02:42 -06:00
Haiko Schol 3d1830a7d5 Implement rendering of nested JSON output (#86) 2018-02-01 19:10:22 +01:00
Haiko Schol 16a1bab007 Add commandline argument --json-tree 2018-01-31 16:18:12 +01:00
Haiko Schol 1262d7ce55 Rename jsonify_tree() to render_json() 2018-01-31 16:05:25 +01:00
Vineet Naik b37c7961a9 Revert "Merge pull request #65 from kdeldycke/filter-dep-tree-before-rendering"
This reverts commit f4fd8b1c25, reversing
changes made to cad03ba86a.
2017-03-19 17:06:46 +05:30
Vineet Naik d3a8efa05b Merge branch 'python_3_graphviz' of https://github.com/jmbowman/pipdeptree into jmbowman-python_3_graphviz
* 'python_3_graphviz' of https://github.com/jmbowman/pipdeptree:
  Install graphviz Python package on Travis
  Fix binary GraphViz output on Python 3
2017-03-05 19:34:06 +05:30
Kevin Deldycke 9c1de2e0b6
Do not replace local tree variable. 2017-02-05 01:11:34 +01:00
Kevin Deldycke 6551d1f2e0
Unittest filter_tree() usage. 2017-02-05 01:08:51 +01:00
Kevin Deldycke b4f0a7be07
Align unittests to new function signatures. 2017-02-05 01:00:05 +01:00
Jeremy Bowman f79143fd04 Fix binary GraphViz output on Python 3 2017-01-25 11:36:18 -05:00
Vineet Naik 67d37e03fa Use 'Any' if specific version is required
Earlier the output said 'None' if a dependency didn't mention a specific
version to install. 'Any' is definitely a better term for this case.

Fixes #57
2017-01-07 12:40:19 +05:30
Vineet Naik a44baabaa5 Try guessing versions of pkgs not listed by pip
* 'pip.get_installed_distributions' doesn't include some packages such
  as 'pip', 'setuptools' etc. so the installed versions for these is not
  available. This change tries to guess the installed version by
  importing the module and checking if the version is defined in
  '__version__' variable.

* Another related change is that the 'required' and 'installed' versions
  will be shown for all intermediate packages. When 'required' is not
  specified, it will show 'None' and when 'installed' is not available,
  it will show '?'. This is to keep the output consistent with the confusing deps
  output.

* Fix indentation in output.

Kind of fixes #46.
2016-08-06 19:14:16 +05:30
Vineet Naik 4ccd84f4de Fix incorrect output in reverse mode
Fixes issues #45 and #49
2016-08-06 17:33:49 +05:30
Vineet Naik ea17d2e558 Simplify code to show confusing deps 2016-08-06 16:08:38 +05:30
Vineet Naik 07bc2c143c Fix failing build
This is done by:

* Forcing tox to install pip version >=8.0.2 inside the virtualenv
* Commenting out a failing assertion. The reason for this failure is
  that the pkgs loaded from the pickled file lose a bit of information
  w.r.t editable packages. This will be fixed properly in soon.
2016-02-14 19:03:41 +05:30
Tom Terrace 41b3fbf9ee replace confusing deps warning with conflicting deps 2015-12-26 09:02:06 -05:00
Tom Terrace 0364d7c2da Add a warning for dependencies that are missing/unsatisfied 2015-12-04 16:17:22 -05:00
Vineet Naik 49965622af Make code compatible with 2.6 and 3.x
- Replaced '.iteritems()' with '.items()'
- Replaced '{k: v for k,v in ..}' with 'dict((k, v) for k,v ..)'
2015-11-09 00:51:37 +05:30
Vineet Naik fdbe63116f Add --reverse flag for showing dep tree in reverse 2015-11-09 00:32:40 +05:30
Vineet Naik 8db536eab3 Majorly refactor the code
The primary reason behind refactoring the code is to be able to make it
straightforward to implement the --reverse mode (ie. instead of showing
package and their sub-deps, it will show the sub-deps and the packages
that need them).

As a part of this change, wrapper classes have been added for
Distribution and Requirements instances that pip returns. These wrapper
classes have handle the rendering of the pkg as a root (top level) and a
branch (non-top level) accordingly. As a result the same function
`render_tree` can be used for --reverse mode.

This change doesn't include the --reverse mode implementation. It will
be added in the subsequent commit.
2015-11-09 00:32:39 +05:30
Vineet Naik d13ff8bdef Modify test workflow
This commit decouples the test virtualenv creation from tox and simplify
it for running both locally and on travis-ci. Creation of the test
virtualenvs now happen via Makefile target 'test-env' which will create
2 virtualenvs in the dir tests/virtualenvs and also dump their
respective package data in .pickle files that will be used by the tests.

Also, builds on travis now no longer depend on tox but reuses some of
the Makefile targets for test virtualenv creation/cleanup.
2015-07-30 00:07:15 +05:30
Vineet Naik db33a5d788 Don't show bullets if freeze option is enabled
This makes the output of pipdeptree (with freeze flag) pip friendly
ie. the output can be saved in a requirements.txt file. At the same time
it's human readable due to indentations for sub-dependencies.

There is however one gotcha! In case pip finds a dependency multiple
times in the requirements.txt file, it fails. So the user will need to
take care about this when dumping the output in requirements.txt.

Fixes #31.
2015-07-26 23:12:10 +05:30
Vineet b429baf01b Use relative paths in pickled virtualenv files
Absolute path causes tests to fail on travis-ci.
2015-03-29 13:30:46 +05:30
Vineet 2eacd1e11b Update venv pickle files fixing tox tests
The pickle files for test virtualenv data were created using an older
version of pip. As tox started using the newer version of pip, these
files were obsolete and it lead to failure of tests run via tox. This is
now fixed by regenerating the pickle files for pip ver. 6.0.8
2015-03-29 13:10:20 +05:30
Vineet 617c46e889 Add tests for function 'peek_into' 2014-10-07 23:28:25 +05:30
Vineet 717e07d492 Move cyclic_deps.pickle inside tests/virtualenvs
for consistency
2014-06-22 21:31:35 +05:30
Marc Abramowitz fd0c477192 Restore Python 2.6 compatibility
c70525bb84 broke Python 2.6 compatibility
by using a dict comprehension, which is a Python 2.7 feature. I replaced
it with calling dict with a generator expression, which looks almost as
good and it works in Python 2.6.
2014-06-17 23:06:46 -07:00
Vineet c70525bb84 Fix failing tests
The tests were failing due to pull requests #14 and #16, which passed tests
individually but lead to failure after both were merged.
2014-06-18 10:28:15 +05:30
Marc Abramowitz e5c03eb91d Fix infinite recursion for cyclic deps
Fixes #13 (https://github.com/naiquevin/pipdeptree/issues/13)
2014-06-17 16:57:08 -07:00
Marc Abramowitz b6eea3084a Add test_render_tree_cyclic_dependency
Test for issue in #13 (https://github.com/naiquevin/pipdeptree/issues/13)
2014-06-16 10:05:30 -07:00