Skip to content

Commit

Permalink
Add tests related to normailization of names
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Nov 3, 2017
1 parent a2d8a28 commit 84a7e21
Showing 1 changed file with 63 additions and 14 deletions.
77 changes: 63 additions & 14 deletions tests/functional/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,74 @@ def test_check_broken_dependency_and_missing_dependency(script):
assert result.returncode == 1


def test_check_complex_names(script):
# Check that uppercase letters and '-' are dealt with
# Setup two small projects
pkga_path = create_test_package_with_setup(
def test_check_complicated_name_missing(script):
package_a_path = create_test_package_with_setup(
script,
name='pkga', version='1.0', install_requires=['Complex_Name==0.1'],
name='package_A', version='1.0',
install_requires=['Dependency-B>=1.0'],
)

complex_path = create_test_package_with_setup(
# Without dependency
result = script.pip('install', '--no-index', package_a_path, '--no-deps')
assert "Successfully installed package-A-1.0" in result.stdout, str(result)

result = script.pip('check', expect_error=True)
expected_lines = (
"package-a 1.0 requires Dependency-B>=1.0, which is not installed.",
)
assert matches_expected_lines(result.stdout, expected_lines)


def test_check_complicated_name_broken(script):
package_a_path = create_test_package_with_setup(
script,
name='Complex-Name', version='0.1',
name='package_A', version='1.0',
install_requires=['Dependency-B>=1.0'],
)
dependency_b_path_incompatible = create_test_package_with_setup(
script,
name='dependency-b', version='0.1',
)

res = script.pip('install', '--no-index', complex_path)
assert "Successfully installed Complex-Name-0.1" in res.stdout, str(res)
# With broken dependency
result = script.pip('install', '--no-index', package_a_path, '--no-deps')
assert "Successfully installed package-A-1.0" in result.stdout, str(result)

res = script.pip('install', '--no-index', pkga_path, '--no-deps')
assert "Successfully installed pkga-1.0" in res.stdout, str(res)
result = script.pip(
'install', '--no-index', dependency_b_path_incompatible, '--no-deps',
)
assert "Successfully installed dependency-b-0.1" in result.stdout

result = script.pip('check', expect_error=True)
expected_lines = (
"package-a 1.0 has requirement Dependency-B>=1.0, but you have "
"dependency-b 0.1.",
)
assert matches_expected_lines(result.stdout, expected_lines)


def test_check_complicated_name_clean(script):
package_a_path = create_test_package_with_setup(
script,
name='package_A', version='1.0',
install_requires=['Dependency-B>=1.0'],
)
dependency_b_path = create_test_package_with_setup(
script,
name='dependency-b', version='1.0',
)

result = script.pip('install', '--no-index', package_a_path, '--no-deps')
assert "Successfully installed package-A-1.0" in result.stdout, str(result)

result = script.pip(
'install', '--no-index', dependency_b_path, '--no-deps',
)
assert "Successfully installed dependency-b-1.0" in result.stdout

result = script.pip('check', expect_error=True)
expected_lines = (
"No broken requirements found.",
)
assert matches_expected_lines(result.stdout, expected_lines)

# Check that Complex_Name is correctly dealt with
res = script.pip('check')
assert "No broken requirements found." in res.stdout, str(res)

0 comments on commit 84a7e21

Please sign in to comment.