Skip to content

Commit 869605d

Browse files
authored
Add directory listing to URL class (#4)
1 parent 0c66d7a commit 869605d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: ada_url/ada_adapter.py

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def __init__(self, url, base=None):
8888
if not lib.ada_is_valid(self.urlobj):
8989
raise ValueError('Invalid input')
9090

91+
def __dir__(self):
92+
return super().__dir__() + list(PARSE_ATTRIBUTES)
93+
9194
def __getattr__(self, attr):
9295
if attr in GET_ATTRIBUTES:
9396
get_func = getattr(lib, f'ada_get_{attr}')

Diff for: tests/test_ada_url.py

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
parse_url,
99
replace_url,
1010
)
11+
from ada_url.ada_adapter import GET_ATTRIBUTES
1112

1213

1314
class ADAURLTests(TestCase):
@@ -86,6 +87,12 @@ def test_class_can_parse_with_base(self):
8687
actual = URL.can_parse(url, base)
8788
self.assertEqual(actual, expected)
8889

90+
def test_class_dir(self):
91+
with URL('https://example.org') as urlobj:
92+
actual = set(dir(urlobj))
93+
94+
self.assertTrue(actual.issuperset(GET_ATTRIBUTES))
95+
8996
def test_check_url(self):
9097
for s, expected in (
9198
('https:example.org', True),

0 commit comments

Comments
 (0)