Skip to content

Conversation

@vladistan
Copy link
Contributor

  • Convert class-level setup/teardown to validation_doc pytest fixture
  • Convert helper methods to standalone functions (_get_normalizer, _assert_unrepaired_types_the_same)
  • Convert all 14 test methods to standalone functions with validation_doc fixture

@vladistan vladistan force-pushed the convert-test-reference-validator-to-pytest branch 2 times, most recently from fa7005b to fcbfb72 Compare September 4, 2025 19:23
@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.41%. Comparing base (f71d115) to head (49218b2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #452   +/-   ##
=======================================
  Coverage   78.41%   78.41%           
=======================================
  Files          52       52           
  Lines        4536     4536           
  Branches      989      989           
=======================================
  Hits         3557     3557           
  Misses        764      764           
  Partials      215      215           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vladistan vladistan marked this pull request as ready for review September 4, 2025 19:33
doc.text("This document describes the validation suite for the LinkML model.")
doc.h2("Core schema")
doc.text("Most tests use the core minimal test schema:")
def _get_normalizer(sb: Optional[SchemaBuilder] = None) -> ReferenceValidator:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you from __future__ import annotations and then use the modern syntax:

sb: SchemaBuilder | None = None

Comment on lines +190 to +191
cases = [
(SlotDefinition("s", multivalued=False), CollectionForm.NonCollection),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this can be shifted into pytest.mark.parametrize

Comment on lines +176 to +177
expected_unrepaired_vals = [_as_type(v) for v in expected_unrepaired]
unrepaired_problem_types_vals = [_as_type(v) for v in unrepaired_problem_types]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just create sets here - then you don't have to worry about sorting them in the next line

obj_simple = {"id": "id1", "name": "name1"}
# cases = form, slot, examples
# example = input, expected_repairs, expected_unrepaired, expected_output
cases = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, use pytest's parametrize here

Comment on lines +1117 to +1118
# for r in report.repaired():
# print(r)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete these bits of commented-out code

Comment on lines +1114 to +1115
for r in report.results_excluding_normalized():
print(yaml_dumper.dumps(r))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete print statements or turn them into tests

Comment on lines +1081 to +1082
for r in report.results_excluding_normalized():
print(yaml_dumper.dumps(r))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete or turn into a test

Comment on lines +1138 to +1139
assert 0 == len(report.errors())
assert 0 == len(report.normalized_results())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yoda condition

@ialarmedalien
Copy link
Collaborator

I didn't look in detail at all of the tests, but there's a lot of code here that can be converted into pytest parameters instead of iterating through it in the unit test.

Copy link
Member

@cmungall cmungall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladistan do you think you'd be able to work switch to parametrizing these?

@vladistan vladistan force-pushed the convert-test-reference-validator-to-pytest branch from 31b5cf8 to b898da9 Compare October 16, 2025 01:49
@amc-corey-cox amc-corey-cox force-pushed the convert-test-reference-validator-to-pytest branch from 3fa5116 to 327f528 Compare October 20, 2025 16:47
@amc-corey-cox
Copy link
Contributor

@vladistan Could you try to get the parametrize work into this PR this week? We'd like to get as many of these PRs merged before our big mono-repo merge between linkml and linkml-runtime
@ialarmedalien and @cmungall it looks to me like this at least moves things along in this test file. If @vladistan can't make the requested changes this week, would it be okay to merge this without the improvements requested?

@amc-corey-cox
Copy link
Contributor

I have moved the work for this PR from the contributor fork to the linkml-runtime branch https://github.com/linkml/linkml-runtime/tree/convert-test-reference-validator-to-pytest . These branches will be lifted over in the merge to the mono-repo so you won't lose you work. You will need to open a new PR against the linkml monorepo after the move. I'd prefer to get this in but if we can't please open a new PR when you resume work. Thanks!

@vladistan vladistan force-pushed the convert-test-reference-validator-to-pytest branch 2 times, most recently from 57fddd7 to 26228e9 Compare October 27, 2025 17:55
- Convert class-level setup/teardown to validation_doc pytest fixture
- Convert helper methods to standalone functions (_get_normalizer, _assert_unrepaired_types_the_same)
- Convert all 14 test methods to standalone functions with validation_doc fixture
@vladistan vladistan force-pushed the convert-test-reference-validator-to-pytest branch from 26228e9 to 49218b2 Compare October 27, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants