def test_url_comparison(): url_a = Url("https://example.org/users/{id}", id=1) url_b = Url("https://example.org/users/{id}", id=1) assert url_a == url_b url_a = Url("https://example.org/users/{id}", id=1) url_b = Url("https://example.org/users/{id}", id=2) assert url_a != url_b
def __init__(self, host, driver): self.url = Url(host) self.driver = driver
def __init__(self, driver: DT): self.url = Url("https://example.com") self.driver: DT = driver
def test_url_join_path(): url = Url("https://example.org") assert url("/users/{id}", id=1) == "https://example.org/users/1" url = Url("https://example.org")("/{version}", version="v1")("/users/{id}", id=1) assert url == "https://example.org/v1/users/1"
def test_invalid_comparison(): url = Url("https://example.org") assert url != 1
def test_url_string_representation(): url = Url("https://example.org") assert url == "https://example.org" url = Url("https://example.org/users/{id}", id=1) assert url == "https://example.org/users/1"
def test_url_representation(): url = Url("https://example.org") assert repr(url) == "Url('https://example.org')" url = Url("https://example.org/users/{id}", id=1) assert repr(url) == "Url('https://example.org/users/{id}', id=1)"