diff --git a/tests/packages/test_locker.py b/tests/packages/test_locker.py index cc16cadeff3..b30e2d3af54 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 @@ -62,8 +62,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" @@ -114,9 +114,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 = [] @@ -126,8 +126,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" @@ -173,8 +173,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" @@ -185,7 +185,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)"] @@ -199,7 +199,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)"] @@ -255,8 +255,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" @@ -267,7 +267,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)"] @@ -315,8 +315,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" @@ -349,8 +349,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" @@ -362,8 +362,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] @@ -385,8 +385,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" @@ -436,8 +436,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" @@ -498,8 +498,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" @@ -527,8 +527,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" @@ -539,7 +539,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" @@ -620,7 +620,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" @@ -631,11 +631,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" @@ -652,8 +652,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" @@ -665,7 +665,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"