Skip to content

Commit 8656c88

Browse files
committed
update test_parser.py to accept free_access as attribute with BaseParser
1 parent fafa941 commit 8656c88

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/fundus/parser/base_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _search_members(cls, obj_type: type) -> List[Tuple[str, Any]]:
172172
@classmethod
173173
def attributes(cls) -> AttributeCollection:
174174
attrs: List[Attribute] = [
175-
func for _, func in cls._search_members(Attribute) if func.__name__ not in ["__ld", "__meta", "free_access"]
175+
func for _, func in cls._search_members(Attribute) if func.__name__ not in ["__ld", "__meta"]
176176
]
177177
return AttributeCollection(*attrs)
178178

tests/test_parser.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def test_functions_iter(self, parser_with_function_test, parser_with_static_meth
4747
assert parser_with_function_test.functions().names == ["test"]
4848

4949
def test_attributes_iter(self, parser_with_attr_title, parser_with_static_method):
50-
assert len(BaseParser.attributes()) == 0
51-
assert len(parser_with_static_method.attributes()) == 0
52-
assert len(parser_with_attr_title.attributes()) == 1
53-
assert parser_with_attr_title.attributes().names == ["title"]
50+
assert len(BaseParser.attributes()) == 1
51+
assert len(parser_with_static_method.attributes()) == 1
52+
assert len(parser_with_attr_title.attributes()) == 2
53+
assert parser_with_attr_title.attributes().names == ["free_access", "title"]
5454

5555
def test_supported_unsupported(self):
5656
class ParserWithValidatedAndUnvalidated(BaseParser):
@@ -63,12 +63,12 @@ def unvalidated(self) -> str:
6363
return "unsupported"
6464

6565
parser = ParserWithValidatedAndUnvalidated()
66-
assert len(parser.attributes()) == 2
66+
assert len(parser.attributes()) == 3
6767

6868
assert (validated := parser.attributes().validated)
6969
assert isinstance(validated, AttributeCollection)
7070
assert (funcs := list(validated)) != [parser.validated]
71-
assert funcs[0].__func__ == parser.validated.__func__
71+
assert funcs[1].__func__ == parser.validated.__func__
7272

7373
assert (unvalidated := parser.attributes().unvalidated)
7474
assert isinstance(validated, AttributeCollection)

0 commit comments

Comments
 (0)