diff --git a/poetry.lock b/poetry.lock index 4b5b4ae..c26c78d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -284,7 +284,7 @@ description = "Internationalized Domain Names in Applications (IDNA)" name = "idna" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "2.9" +version = "2.10" [[package]] category = "dev" @@ -1244,8 +1244,8 @@ future = [ {file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"}, ] idna = [ - {file = "idna-2.9-py2.py3-none-any.whl", hash = "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"}, - {file = "idna-2.9.tar.gz", hash = "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb"}, + {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, + {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, ] importlib-metadata = [ {file = "importlib_metadata-1.7.0-py2.py3-none-any.whl", hash = "sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070"}, diff --git a/pomace/api.py b/pomace/api.py index 91658cd..202512c 100644 --- a/pomace/api.py +++ b/pomace/api.py @@ -1,4 +1,7 @@ import atexit +import inspect +import os +from pathlib import Path from typing import Optional import log @@ -31,6 +34,10 @@ def visit( log.silence('urllib3.connectionpool') atexit.register(utils.quit_browser, silence_logging=True) + frame = inspect.getouterframes(inspect.currentframe())[1] + path = Path(frame.filename) + os.chdir(path.parent) + return models.autopage() diff --git a/pyproject.toml b/pyproject.toml index 7717ede..19bcdbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "pomace" -version = "0.0.15" +version = "0.0.16" description = "Dynamic page objects for browser automation." license = "MIT" diff --git a/tests/test_api.py b/tests/test_api.py index 1da5219..ef650f8 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,4 +1,6 @@ -# pylint: disable=unused-variable +# pylint: disable=unused-variable,expression-not-assigned + +from pathlib import Path import pomace @@ -7,3 +9,8 @@ def describe_visit(): def it_launches_a_browser(expect): page = pomace.visit("http://example.com", browser='chrome', headless=True) expect(page).contains("Example Domain") + + def it_saves_data_relative_caller(expect): + page = pomace.visit("http://example.com", browser='chrome', headless=True) + path = Path(__file__).parent / 'sites' / 'example.com' / '@' / 'default.yml' + expect(page.datafile.path) == path.resolve()