From 936a0fdc049f6322588aeaafd19fa32d811609f9 Mon Sep 17 00:00:00 2001 From: Vishal Kuo Date: Thu, 16 Jun 2022 11:51:47 -0700 Subject: [PATCH] code review --- tests/packages/test_locker.py | 78 +++++++++++++++++------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/packages/test_locker.py b/tests/packages/test_locker.py index 7669c21835d..17f8b8c79dc 100644 --- a/tests/packages/test_locker.py +++ b/tests/packages/test_locker.py @@ -17,7 +17,7 @@ from poetry.core.semver.version import Version from poetry.factory import Factory -from poetry.packages.locker import Locker +from poetry.packages.locker import Locker, GENERATED_COMMENT from tests.helpers import get_dependency from tests.helpers import get_package @@ -81,8 +81,8 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage): with locker.lock.open(encoding="utf-8") as f: content = f.read() - expected = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + expected = f"""\ +# {GENERATED_COMMENT} [[package]] name = "A" @@ -157,9 +157,9 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage): [metadata.files] A = [ - {file = "bar", hash = "123"}, - {file = "foo", hash = "456"}, - {file = "baz", hash = "345"}, + {{file = "bar", hash = "123"}}, + {{file = "foo", hash = "456"}}, + {{file = "baz", hash = "345"}}, ] B = [] git-package = [] @@ -170,8 +170,8 @@ def test_lock_file_data_is_ordered(locker: Locker, root: ProjectPackage): def test_locker_properly_loads_extras(locker: Locker): - content = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + content = f"""\ +# {GENERATED_COMMENT} [[package]] name = "cachecontrol" @@ -217,8 +217,8 @@ def test_locker_properly_loads_extras(locker: Locker): def test_locker_properly_loads_nested_extras(locker: Locker): - content = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + content = f"""\ +# {GENERATED_COMMENT} [[package]] name = "a" @@ -229,7 +229,7 @@ def test_locker_properly_loads_nested_extras(locker: Locker): python-versions = "*" [package.dependencies] -b = {version = "^1.0", optional = true, extras = "c"} +b = {{version = "^1.0", optional = true, extras = "c"}} [package.extras] b = ["b[c] (>=1.0,<2.0)"] @@ -243,7 +243,7 @@ def test_locker_properly_loads_nested_extras(locker: Locker): python-versions = "*" [package.dependencies] -c = {version = "^1.0", optional = true} +c = {{version = "^1.0", optional = true}} [package.extras] c = ["c (>=1.0,<2.0)"] @@ -299,8 +299,8 @@ def test_locker_properly_loads_nested_extras(locker: Locker): def test_locker_properly_loads_extras_legacy(locker: Locker): - content = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + content = f"""\ +# {GENERATED_COMMENT} [[package]] name = "a" @@ -311,7 +311,7 @@ def test_locker_properly_loads_extras_legacy(locker: Locker): python-versions = "*" [package.dependencies] -b = {version = "^1.0", optional = true} +b = {{version = "^1.0", optional = true}} [package.extras] b = ["b (^1.0)"] @@ -359,8 +359,8 @@ def test_lock_packages_with_null_description(locker: Locker, root: ProjectPackag with locker.lock.open(encoding="utf-8") as f: content = f.read() - expected = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + expected = f"""\ +# {GENERATED_COMMENT} [[package]] name = "A" @@ -393,8 +393,8 @@ def test_lock_file_should_not_have_mixed_types(locker: Locker, root: ProjectPack locker.set_lock_data(root, [package_a]) - expected = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + expected = f"""\ +# {GENERATED_COMMENT} [[package]] name = "A" @@ -406,8 +406,8 @@ def test_lock_file_should_not_have_mixed_types(locker: Locker, root: ProjectPack [package.dependencies] B = [ - {version = "^1.0.0"}, - {version = ">=1.0.0", optional = true}, + {{version = "^1.0.0"}}, + {{version = ">=1.0.0", optional = true}}, ] [package.extras] @@ -429,8 +429,8 @@ def test_lock_file_should_not_have_mixed_types(locker: Locker, root: ProjectPack def test_reading_lock_file_should_raise_an_error_on_invalid_data(locker: Locker): - content = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + content = f"""\ +# {GENERATED_COMMENT} [[package]] name = "A" @@ -480,8 +480,8 @@ def test_locking_legacy_repository_package_should_include_source_section( with locker.lock.open(encoding="utf-8") as f: content = f.read() - expected = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + expected = f"""\ +# {GENERATED_COMMENT} [[package]] name = "A" @@ -542,8 +542,8 @@ def test_locker_should_emit_warnings_if_lock_version_is_newer_but_allowed( def test_locker_should_raise_an_error_if_lock_version_is_newer_and_not_allowed( locker: Locker, caplog: LogCaptureFixture ): - content = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + content = f"""\ +# {GENERATED_COMMENT} [metadata] lock-version = "2.0" @@ -571,8 +571,8 @@ def test_extras_dependencies_are_ordered(locker: Locker, root: ProjectPackage): locker.set_lock_data(root, [package_a]) - expected = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + expected = f"""\ +# {GENERATED_COMMENT} [[package]] name = "A" @@ -583,7 +583,7 @@ def test_extras_dependencies_are_ordered(locker: Locker, root: ProjectPackage): python-versions = "*" [package.dependencies] -B = {version = "^1.0.0", extras = ["a", "b", "c"], optional = true} +B = {{version = "^1.0.0", extras = ["a", "b", "c"], optional = true}} [metadata] lock-version = "1.1" @@ -664,7 +664,7 @@ def test_locker_dumps_dependency_information_correctly( with locker.lock.open(encoding="utf-8") as f: content = f.read() - expected = """# This file is automatically @generated by Poetry and should not be changed by hand. + expected = f"""# {GENERATED_COMMENT} [[package]] name = "A" @@ -675,11 +675,11 @@ def test_locker_dumps_dependency_information_correctly( python-versions = "*" [package.dependencies] -B = {path = "project_with_extras", develop = true} -C = {path = "directory/project_with_transitive_directory_dependencies"} -D = {path = "distributions/demo-0.1.0.tar.gz"} -E = {url = "https://python-poetry.org/poetry-1.2.0.tar.gz"} -F = {git = "https://github.com/python-poetry/poetry.git", branch = "foo"} +B = {{path = "project_with_extras", develop = true}} +C = {{path = "directory/project_with_transitive_directory_dependencies"}} +D = {{path = "distributions/demo-0.1.0.tar.gz"}} +E = {{url = "https://python-poetry.org/poetry-1.2.0.tar.gz"}} +F = {{git = "https://github.com/python-poetry/poetry.git", branch = "foo"}} [metadata] lock-version = "1.1" @@ -696,8 +696,8 @@ def test_locker_dumps_dependency_information_correctly( def test_locked_repository_uses_root_dir_of_package( locker: Locker, mocker: MockerFixture ): - content = """\ -# This file is automatically @generated by Poetry and should not be changed by hand. + content = f"""\ +# {GENERATED_COMMENT} [[package]] name = "lib-a" @@ -709,7 +709,7 @@ def test_locked_repository_uses_root_dir_of_package( develop = true [package.dependencies] -lib-b = {path = "../libB", develop = true} +lib-b = {{path = "../libB", develop = true}} [package.source] type = "directory"