|
3 | 3 |
|
4 | 4 | import pytest
|
5 | 5 |
|
| 6 | +from tests.lib import create_test_package_with_setup |
6 | 7 | from tests.lib.path import Path
|
7 | 8 |
|
8 | 9 |
|
@@ -543,3 +544,44 @@ def test_list_path_multiple(tmpdir, script, data):
|
543 | 544 | json_result = json.loads(result.stdout)
|
544 | 545 | assert {'name': 'simple', 'version': '2.0'} in json_result
|
545 | 546 | assert {'name': 'simple2', 'version': '3.0'} in json_result
|
| 547 | + |
| 548 | + |
| 549 | +def test_list_skip_work_dir_pkg(script): |
| 550 | + """ |
| 551 | + Test that list should not include package in working directory |
| 552 | + """ |
| 553 | + |
| 554 | + # Create a test package and create .egg-info dir |
| 555 | + pkg_path = create_test_package_with_setup(script, |
| 556 | + name='simple', |
| 557 | + version='1.0') |
| 558 | + script.run('python', 'setup.py', 'egg_info', |
| 559 | + expect_stderr=True, cwd=pkg_path) |
| 560 | + |
| 561 | + # List should not include package simple when run from package directory |
| 562 | + result = script.pip('list', '--format=json', cwd=pkg_path) |
| 563 | + json_result = json.loads(result.stdout) |
| 564 | + assert {'name': 'simple', 'version': '1.0'} not in json_result |
| 565 | + |
| 566 | + |
| 567 | +def test_list_include_work_dir_pkg(script): |
| 568 | + """ |
| 569 | + Test that list should include package in working directory |
| 570 | + if working directory is added in sys.path |
| 571 | + """ |
| 572 | + |
| 573 | + # Create a test package and create .egg-info dir |
| 574 | + pkg_path = create_test_package_with_setup(script, |
| 575 | + name='simple', |
| 576 | + version='1.0') |
| 577 | + |
| 578 | + script.run('python', 'setup.py', 'egg_info', |
| 579 | + expect_stderr=True, cwd=pkg_path) |
| 580 | + |
| 581 | + # Add PYTHONPATH env variable |
| 582 | + script.environ.update({'PYTHONPATH': pkg_path}) |
| 583 | + |
| 584 | + # List should include package simple when run from package directory |
| 585 | + result = script.pip('list', '--format=json', cwd=pkg_path) |
| 586 | + json_result = json.loads(result.stdout) |
| 587 | + assert {'name': 'simple', 'version': '1.0'} in json_result |
0 commit comments