From a1c3a063469d2dade38b14dfba1a57e297ca7646 Mon Sep 17 00:00:00 2001 From: dasm Date: Mon, 9 Jan 2023 16:50:37 -0800 Subject: [PATCH 1/5] Make sure Poetry.export includes credentials. --- src/nox_poetry/poetry.py | 1 + .../simple503/bar-0.1.0-py2.py3-none-any.whl | Bin 0 -> 931 bytes .../bar-0.1.0-py2.py3-none-any.whl.metadata | 14 +++ tests/unit/data/simple503/bar/index.html | 20 +++++ tests/unit/data/simple503/index.html | 17 ++++ tests/unit/test_poetry.py | 83 ++++++++++++++++++ 6 files changed, 135 insertions(+) create mode 100644 tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl create mode 100644 tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl.metadata create mode 100644 tests/unit/data/simple503/bar/index.html create mode 100644 tests/unit/data/simple503/index.html diff --git a/src/nox_poetry/poetry.py b/src/nox_poetry/poetry.py index e56299fe..8f04fd23 100644 --- a/src/nox_poetry/poetry.py +++ b/src/nox_poetry/poetry.py @@ -85,6 +85,7 @@ def export(self) -> str: "--dev", *[f"--extras={extra}" for extra in self.config.extras], "--without-hashes", + "--with-credentials", external=True, silent=True, stderr=None, diff --git a/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl b/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..fe49df27cbc94aad90a57427bcf52c9c946502ca GIT binary patch literal 931 zcmWIWW@Zs#U|`??VnrZkU|<513=I50Iw`S8KR!M)FS8^*Uaz2%nIQmKxre|mjhW#< zWidc32~n-6Rcr>N_IBf=w~@i z6U7a-T>rnWJXDb7d&fpGAMVWe1^44z3(kw3v%Eh+xqMgf@}pC?K8;f1k+{>@qI}2W zuKhQO3%gINI9dJQ_0e_hQ}?vqf@`y;xDW&HQaIclFyQs;4f#Jg5 zbj}$Gi&8JL&YI%y+}+}IT8-IF#VAPXV4(l~sn+)y<6>v-oU-fs;wj$>n4fPeI`K(# zy~b_6m&7i<;5!tG@2!LoV%=_Hq(9Ynd&Lw zlZEZ9xXMp&Iq7=MeU5& zX50x67z|*rq!C1+B||jL7|9T#m4RUiqdr74_C$$p40`%O7_%3LF|gExZW4NoB1|d; c#xc-07!HEOZ-6%|8%Qk+5Q+g+mV@&m0I2mQj{pDw literal 0 HcmV?d00001 diff --git a/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl.metadata b/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl.metadata new file mode 100644 index 00000000..05ab143a --- /dev/null +++ b/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl.metadata @@ -0,0 +1,14 @@ +Metadata-Version: 2.1 +Name: bar +Version: 0.1.0 +Summary: bar +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 diff --git a/tests/unit/data/simple503/bar/index.html b/tests/unit/data/simple503/bar/index.html new file mode 100644 index 00000000..deedf802 --- /dev/null +++ b/tests/unit/data/simple503/bar/index.html @@ -0,0 +1,20 @@ + + + + + + + + Links for bar + + + +

+ Links for bar +

+ + bar-0.1.0-py2.py3-none-any.whl + +
+ + diff --git a/tests/unit/data/simple503/index.html b/tests/unit/data/simple503/index.html new file mode 100644 index 00000000..8b4a4fea --- /dev/null +++ b/tests/unit/data/simple503/index.html @@ -0,0 +1,17 @@ + + + + + + + + Simple Package Repository + + + + + bar + +
+ + diff --git a/tests/unit/test_poetry.py b/tests/unit/test_poetry.py index d7ce94f3..a2e663a7 100644 --- a/tests/unit/test_poetry.py +++ b/tests/unit/test_poetry.py @@ -1,7 +1,15 @@ """Unit tests for the poetry module.""" +import os +import pdb +import tempfile +from functools import partial +from http.server import HTTPServer +from http.server import SimpleHTTPRequestHandler from pathlib import Path +from threading import Thread from typing import Any from typing import Dict +from typing import Tuple import nox._options import nox.command @@ -61,3 +69,78 @@ def _run(*args: Any, **kwargs: Any) -> str: output = poetry.Poetry(session).export() assert output == requirements + + +def get_pyproject(address: str) -> str: + return f"""\ +[tool.poetry] +name = "foo" +version = "0.1.0" +description = "foo" +authors = [] + +[tool.poetry.dependencies] +"bar" = {{version = "0.1.0", source = "baz"}} + +[[tool.poetry.source]] +name = "baz" +url = "{address}" +default = false +secondary = true +""" + + +def serve_directory_with_http(directory: str) -> Tuple[HTTPServer, str]: + hostname = "localhost" + port = 0 + handler = partial(SimpleHTTPRequestHandler, directory=directory) + httpd = HTTPServer((hostname, port), handler, False) + httpd.timeout = 0.5 + + httpd.server_bind() + address = "http://%s:%d" % (hostname, httpd.server_port) + + httpd.server_activate() + + def serve_forever(httpd: HTTPServer) -> None: + with httpd: # to make sure httpd.server_close is called + httpd.serve_forever() + + thread = Thread(target=serve_forever, args=(httpd,)) + thread.setDaemon(True) + thread.start() + + return httpd, address + + +@nox.session +def test_export_with_source_credentials( + session: nox.Session, shared_datadir: Path +) -> None: + input_dir = tempfile.TemporaryDirectory() + + server, address = serve_directory_with_http(str(shared_datadir / "simple503")) + + with open(os.path.join(input_dir.name, "pyproject.toml"), "w") as pyproject_file: + pyproject_file.write(get_pyproject(address)) + + cwd = os.getcwd() + try: + os.chdir(input_dir.name) + session.run_always( + "poetry", + "config", + "http-basic.baz", + "alice", + "password", + external=True, + silent=True, + stderr=None, + ) + test_poetry = poetry.Poetry(session) + resources_file = test_poetry.export() + expected_index = "http://alice:password@" + address.lstrip("http://") + assert f"--extra-index-url {expected_index}" in resources_file + finally: + os.chdir(cwd) + server.shutdown() From a40490969ecd544cba4afb0707455b868a96e1a8 Mon Sep 17 00:00:00 2001 From: dasm Date: Mon, 9 Jan 2023 17:52:53 -0800 Subject: [PATCH 2/5] Change private repository package to avoid conflict with package 'bar' on pypi. --- tests/unit/data/simple503/bar/index.html | 20 ------------------ tests/unit/data/simple503/index.html | 4 ++-- ...gedoesnotexist-0.1.0-py2.py3-none-any.whl} | Bin ...exist-0.1.0-py2.py3-none-any.whl.metadata} | 0 .../thispackagedoesnotexist/index.html | 20 ++++++++++++++++++ tests/unit/test_poetry.py | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 tests/unit/data/simple503/bar/index.html rename tests/unit/data/simple503/{bar-0.1.0-py2.py3-none-any.whl => thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl} (100%) rename tests/unit/data/simple503/{bar-0.1.0-py2.py3-none-any.whl.metadata => thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata} (100%) create mode 100644 tests/unit/data/simple503/thispackagedoesnotexist/index.html diff --git a/tests/unit/data/simple503/bar/index.html b/tests/unit/data/simple503/bar/index.html deleted file mode 100644 index deedf802..00000000 --- a/tests/unit/data/simple503/bar/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - Links for bar - - - -

- Links for bar -

- - bar-0.1.0-py2.py3-none-any.whl - -
- - diff --git a/tests/unit/data/simple503/index.html b/tests/unit/data/simple503/index.html index 8b4a4fea..9fc90ddc 100644 --- a/tests/unit/data/simple503/index.html +++ b/tests/unit/data/simple503/index.html @@ -9,8 +9,8 @@ - - bar + + thispackagedoesnotexist
diff --git a/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl b/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl similarity index 100% rename from tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl rename to tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl diff --git a/tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl.metadata b/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata similarity index 100% rename from tests/unit/data/simple503/bar-0.1.0-py2.py3-none-any.whl.metadata rename to tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata diff --git a/tests/unit/data/simple503/thispackagedoesnotexist/index.html b/tests/unit/data/simple503/thispackagedoesnotexist/index.html new file mode 100644 index 00000000..c5bef8b0 --- /dev/null +++ b/tests/unit/data/simple503/thispackagedoesnotexist/index.html @@ -0,0 +1,20 @@ + + + + + + + + Links for thispackagedoesnotexist + + + +

+ Links for thispackagedoesnotexist +

+ + thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl + +
+ + diff --git a/tests/unit/test_poetry.py b/tests/unit/test_poetry.py index a2e663a7..c6451d7f 100644 --- a/tests/unit/test_poetry.py +++ b/tests/unit/test_poetry.py @@ -80,7 +80,7 @@ def get_pyproject(address: str) -> str: authors = [] [tool.poetry.dependencies] -"bar" = {{version = "0.1.0", source = "baz"}} +"thispackagedoesnotexist" = {{version = "0.1.0", source = "baz"}} [[tool.poetry.source]] name = "baz" From d02d162a62f5aa4aae401aedf2f7d46cc2f281eb Mon Sep 17 00:00:00 2001 From: dasm Date: Mon, 9 Jan 2023 18:02:17 -0800 Subject: [PATCH 3/5] Fix change to thispackagedoesnotexist. --- ...kagedoesnotexist-0.1.0-py2.py3-none-any.whl | Bin 931 -> 1123 bytes ...otexist-0.1.0-py2.py3-none-any.whl.metadata | 4 ++-- .../thispackagedoesnotexist/index.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl b/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl index fe49df27cbc94aad90a57427bcf52c9c946502ca..433d59c7259357e0feb0c221d562b9d5abf10414 100644 GIT binary patch literal 1123 zcmWIWW@Zs#U|`??VnrZkU|<513=GOZx+EjBxF9h(J25>qB|o(|FTW(UBD1(eKR!M) zFS8^*Uaz2%nIQn#2oHf>8Z*OzT4R7%7q=0*26~2i26`z#({wZQ((?7gJzQOVL{C|B zH5dr69H)%U_fJO`2ni<7MSHIoG$Ou{hU?m6~yF z60>p*e0kheYdEQ?~a2T^0)TsR0Qt z^mPq!ba4!EoO<4t?~nmc+e2HRBR5?7G=Hk7fRNB`SKq9QDjI&ORn?~s9eZ&0*B85H z|B#J`ySk-CAI{m6yU;Mb=Sl9{$heC7qy>7Dm&Ck08+2B`^g@I2bwf9u%m4owEa0%8 z(Y1a0B9_t zeKs@NR`U+fM`4T%407y3*+YzDU|7QFjN3r$nE>5r^z@1_`Y8!U!%{E0>F8+&Vfubx cD#8&G7!HS|pa5@HHjsW6AWQ@5ehw~602c~)%K!iX delta 604 zcmaFNv6y{=6gxiy14B|`(L_@Xc1b9+qFUHyyV9vTAXk@(fk6f$JXwlSx_&R0lOYf5 zgT4L}#SOMx|G%z0RFLI+$3`(9?#%ZE_v2g(&WoM1ygxy?d{^-Dqf@s&jZ)%~xYOC9 ze8=Oi{WpmVyHBe)S^eMj(RJ-p_q5)EYqO@f6nPdbn55>#^KtU|zmccEORcHCBX#uB zuH#c9*PKmC7JIh8FkP&AGsnHXi~-)v^(-Pl$8Z3#qQ?cH1^K6dEH*|41}TUWbq(|k z^$hebm-W+Ty6-(xJtcgyu$>iG`ROeuU9Y*X(!Coo{iL<& zkNm%Hf0<8_>DiUwaN^a=nVZh0doj-VYs4Jj&B!Fe3=ajMzZn>SaRdgSsDyzfjUW~< zVkhe`Ylwnk76z6u>I0b|nObHwMf8Y9sM-rvb%R+`5k0ICs!D;O4>HS)MVU(s$Swyv F1_0?1(WC$X diff --git a/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata b/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata index 05ab143a..1ef725f1 100644 --- a/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata +++ b/tests/unit/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata @@ -1,7 +1,7 @@ Metadata-Version: 2.1 -Name: bar +Name: thispackagedoesnotexist Version: 0.1.0 -Summary: bar +Summary: thispackagedoesnotexist Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 diff --git a/tests/unit/data/simple503/thispackagedoesnotexist/index.html b/tests/unit/data/simple503/thispackagedoesnotexist/index.html index c5bef8b0..ceaef7f2 100644 --- a/tests/unit/data/simple503/thispackagedoesnotexist/index.html +++ b/tests/unit/data/simple503/thispackagedoesnotexist/index.html @@ -12,7 +12,7 @@

Links for thispackagedoesnotexist

- + thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl
From d9e341c3252313a2c8f79e8d3c21d62a34ce8f16 Mon Sep 17 00:00:00 2001 From: dasm Date: Tue, 10 Jan 2023 14:37:18 -0800 Subject: [PATCH 4/5] Allow nox-poetry to install from private package indexes. Make sure we pass additional sources specified by poetry to pip. Also add an end-to-end test to verify that we can install from a private index that requires authentication. --- src/nox_poetry/sessions.py | 2 + tests/functional/data/simple503/index.html | 17 +++ ...agedoesnotexist-0.1.0-py2.py3-none-any.whl | Bin 0 -> 1123 bytes ...texist-0.1.0-py2.py3-none-any.whl.metadata | 14 ++ .../thispackagedoesnotexist/index.html | 20 +++ tests/functional/test_installroot.py | 142 ++++++++++++++++++ tests/unit/test_sessions.py | 13 +- 7 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 tests/functional/data/simple503/index.html create mode 100644 tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl create mode 100644 tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata create mode 100644 tests/functional/data/simple503/thispackagedoesnotexist/index.html diff --git a/src/nox_poetry/sessions.py b/src/nox_poetry/sessions.py index 9d451147..f0c84333 100644 --- a/src/nox_poetry/sessions.py +++ b/src/nox_poetry/sessions.py @@ -58,6 +58,8 @@ def _split_extras(arg: str) -> Tuple[str, Optional[str]]: def to_constraint(requirement_string: str, line: int) -> Optional[str]: """Convert requirement to constraint.""" + if requirement_string.startswith("--extra-index-url"): + return requirement_string if any( requirement_string.startswith(prefix) for prefix in ("-", "file://", "git+https://", "http://", "https://") diff --git a/tests/functional/data/simple503/index.html b/tests/functional/data/simple503/index.html new file mode 100644 index 00000000..9fc90ddc --- /dev/null +++ b/tests/functional/data/simple503/index.html @@ -0,0 +1,17 @@ + + + + + + + + Simple Package Repository + + + + + thispackagedoesnotexist + +
+ + diff --git a/tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl b/tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..433d59c7259357e0feb0c221d562b9d5abf10414 GIT binary patch literal 1123 zcmWIWW@Zs#U|`??VnrZkU|<513=GOZx+EjBxF9h(J25>qB|o(|FTW(UBD1(eKR!M) zFS8^*Uaz2%nIQn#2oHf>8Z*OzT4R7%7q=0*26~2i26`z#({wZQ((?7gJzQOVL{C|B zH5dr69H)%U_fJO`2ni<7MSHIoG$Ou{hU?m6~yF z60>p*e0kheYdEQ?~a2T^0)TsR0Qt z^mPq!ba4!EoO<4t?~nmc+e2HRBR5?7G=Hk7fRNB`SKq9QDjI&ORn?~s9eZ&0*B85H z|B#J`ySk-CAI{m6yU;Mb=Sl9{$heC7qy>7Dm&Ck08+2B`^g@I2bwf9u%m4owEa0%8 z(Y1a0B9_t zeKs@NR`U+fM`4T%407y3*+YzDU|7QFjN3r$nE>5r^z@1_`Y8!U!%{E0>F8+&Vfubx cD#8&G7!HS|pa5@HHjsW6AWQ@5ehw~602c~)%K!iX literal 0 HcmV?d00001 diff --git a/tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata b/tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata new file mode 100644 index 00000000..1ef725f1 --- /dev/null +++ b/tests/functional/data/simple503/thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl.metadata @@ -0,0 +1,14 @@ +Metadata-Version: 2.1 +Name: thispackagedoesnotexist +Version: 0.1.0 +Summary: thispackagedoesnotexist +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 diff --git a/tests/functional/data/simple503/thispackagedoesnotexist/index.html b/tests/functional/data/simple503/thispackagedoesnotexist/index.html new file mode 100644 index 00000000..44a5c5bd --- /dev/null +++ b/tests/functional/data/simple503/thispackagedoesnotexist/index.html @@ -0,0 +1,20 @@ + + + + + + + + Links for thispackagedoesnotexist + + + +

+ Links for thispackagedoesnotexist +

+ + thispackagedoesnotexist-0.1.0-py2.py3-none-any.whl + +
+ + diff --git a/tests/functional/test_installroot.py b/tests/functional/test_installroot.py index 4daf07a1..097a9a76 100644 --- a/tests/functional/test_installroot.py +++ b/tests/functional/test_installroot.py @@ -1,4 +1,15 @@ """Functional tests for ``installroot``.""" +import base64 +import os +import tempfile +from functools import partial +from http.server import HTTPServer +from http.server import SimpleHTTPRequestHandler +from pathlib import Path +from threading import Thread +from typing import Any +from typing import Tuple + import nox_poetry from tests.functional.conftest import Project from tests.functional.conftest import list_packages @@ -79,3 +90,134 @@ def test(session: nox_poetry.Session) -> None: packages = list_packages(project, test) assert set(expected) == set(packages) + + +class AuthenticatingSimpleHTTPRequestHandler(SimpleHTTPRequestHandler): + """A version of SimpleHTTPRequestHandler that throws a 401 error if the request + does not come with the specified username and password sent via basic http + authentication. See RFC 7617 for details. This is designed for tests, and does not + offer any real protection.""" + + def __init__( + self, + request: Any, + client_address: Any, + server: Any, + directory: Any, + username: str, + password: str, + ): + authstring = f"{username}:{password}" + self.encoded_authstring = base64.b64encode(authstring.encode("utf-8")).decode( + "utf-8" + ) + super().__init__(request, client_address, server, directory=directory) + + def is_authenticated(self) -> bool: + if "Authorization" in self.headers: + return bool( + self.headers["Authorization"] == f"Basic {self.encoded_authstring}" + ) + return False + + def send_auth_error(self) -> None: + self.send_response(401) + self.send_header("WWW-Authenticate", 'Basic realm="everything"') + self.end_headers() + + def do_GET(self) -> None: + if self.is_authenticated(): + super().do_GET() + else: + self.send_auth_error() + + def do_HEAD(self) -> None: + if self.is_authenticated(): + super().do_HEAD() + else: + self.send_auth_error() + + +def get_pyproject(address: str) -> str: + return f"""\ +[tool.poetry] +name = "foo" +version = "0.1.1" +description = "foo" +authors = [] + +[tool.poetry.dependencies] +"thispackagedoesnotexist" = {{version = "0.1.0", source = "baz"}} + +[[tool.poetry.source]] +name = "baz" +url = "{address}" +default = false +secondary = true +""" + + +def serve_directory_with_http_and_auth( + directory: str, username: str, password: str +) -> Tuple[HTTPServer, str]: + hostname = "localhost" + port = 0 + handler = partial( + AuthenticatingSimpleHTTPRequestHandler, + directory=directory, + username=username, + password=password, + ) + httpd = HTTPServer((hostname, port), handler, False) + httpd.timeout = 0.5 + + httpd.server_bind() + address = "http://%s:%d" % (hostname, httpd.server_port) + + httpd.server_activate() + + def serve_forever(httpd: HTTPServer) -> None: + with httpd: # to make sure httpd.server_close is called + httpd.serve_forever() + + thread = Thread(target=serve_forever, args=(httpd,)) + thread.setDaemon(True) + thread.start() + + return httpd, address + + +def test_dependency_from_private_index(shared_datadir: Path) -> None: + input_dir = tempfile.TemporaryDirectory() + + server, address = serve_directory_with_http_and_auth( + str(shared_datadir / "simple503"), username="alice", password="password" + ) + + with open(os.path.join(input_dir.name, "pyproject.toml"), "w") as pyproject_file: + pyproject_file.write(get_pyproject(address)) + (Path(input_dir.name) / "foo").mkdir() + (Path(input_dir.name) / "foo" / "__init__.py").touch() + + @nox_poetry.session + def test(session: nox_poetry.Session) -> None: + session.run_always( + "poetry", + "config", + "http-basic.baz", + "alice", + "password", + external=True, + silent=True, + stderr=None, + ) + session.run_always("poetry", "lock") + session.poetry.installroot() + + project = Project(Path(input_dir.name)) + + try: + run_nox_with_noxfile(project, [test], [nox_poetry]) + + finally: + server.shutdown() diff --git a/tests/unit/test_sessions.py b/tests/unit/test_sessions.py index 13516c52..f568a371 100644 --- a/tests/unit/test_sessions.py +++ b/tests/unit/test_sessions.py @@ -161,8 +161,18 @@ def test_session_build_package(proxy: nox_poetry.Session) -> None: 'regex==2020.10.28; python_version == "3.5"', ), ("-e ../lib/foo", ""), - ("--extra-index-url https://example.com/pypi/simple", ""), ( + "--extra-index-url https://example.com/pypi/simple", + "--extra-index-url https://example.com/pypi/simple", + ), + ( + dedent( + """ + --extra-index-url https://example.com/pypi/simple + + boltons==20.2.1 + """ + ), dedent( """ --extra-index-url https://example.com/pypi/simple @@ -170,7 +180,6 @@ def test_session_build_package(proxy: nox_poetry.Session) -> None: boltons==20.2.1 """ ), - "boltons==20.2.1", ), ], ) From a7e99eb34d147003d2043581135a3b85adf5394e Mon Sep 17 00:00:00 2001 From: dasm Date: Tue, 10 Jan 2023 15:03:58 -0800 Subject: [PATCH 5/5] Fix failing test. --- tests/unit/test_sessions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_sessions.py b/tests/unit/test_sessions.py index f568a371..a4a1e43a 100644 --- a/tests/unit/test_sessions.py +++ b/tests/unit/test_sessions.py @@ -176,10 +176,11 @@ def test_session_build_package(proxy: nox_poetry.Session) -> None: dedent( """ --extra-index-url https://example.com/pypi/simple - boltons==20.2.1 """ - ), + ) + .lstrip("\n") + .rstrip("\n"), ), ], )