Commit 9ba25bc3 by Adam Wojtczak Committed by Bjorn Neergaard

fix: run installer tests from any directory

Locker will set package.source_url relative to lock path, this
made it so that tests were failing if run outside root directory
because lock path was set to Path(__file__).

With using project_root fixture as lock path now tests can be run
from any directory.
parent 7f70c38e
......@@ -405,3 +405,8 @@ def command_tester_factory(app, env):
def do_lock(command_tester_factory, poetry):
command_tester_factory("lock").execute()
assert poetry.locker.lock.exists()
@pytest.fixture
def project_root():
return Path(__file__).parent.parent
......@@ -85,8 +85,8 @@ class CustomInstalledRepository(InstalledRepository):
class Locker(BaseLocker):
def __init__(self):
self._lock = TOMLFile(Path.cwd().joinpath("poetry.lock"))
def __init__(self, lock_path):
self._lock = TOMLFile(Path(lock_path).joinpath("poetry.lock"))
self._written_data = None
self._locked = False
self._content_hash = self._get_content_hash()
......@@ -153,8 +153,8 @@ def installed():
@pytest.fixture()
def locker():
return Locker()
def locker(project_root):
return Locker(lock_path=project_root)
@pytest.fixture()
......
......@@ -41,8 +41,8 @@ class CustomInstalledRepository(InstalledRepository):
class Locker(BaseLocker):
def __init__(self):
self._lock = TOMLFile(Path.cwd().joinpath("poetry.lock"))
def __init__(self, lock_path):
self._lock = TOMLFile(Path(lock_path).joinpath("poetry.lock"))
self._written_data = None
self._locked = False
self._content_hash = self._get_content_hash()
......@@ -109,8 +109,8 @@ def installed():
@pytest.fixture()
def locker():
return Locker()
def locker(project_root):
return Locker(lock_path=project_root)
@pytest.fixture()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment