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 from 17727b0 to fa7005b Compare September 4, 2025 19:14
- 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 fa7005b to fcbfb72 Compare September 4, 2025 19:23
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.38%. Comparing base (66b3861) to head (31b5cf8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #452   +/-   ##
=======================================
  Coverage   77.38%   77.38%           
=======================================
  Files          52       52           
  Lines        4479     4479           
  Branches      979      979           
=======================================
  Hits         3466     3466           
  Misses        785      785           
  Partials      228      228           

☔ 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.

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.

2 participants