-
Notifications
You must be signed in to change notification settings - Fork 54
- F async combination approvals #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
JayBazuzi
wants to merge
1
commit into
main
Choose a base branch
from
JayBazuzi/async_combination_approvals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+99
−7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reviewer's GuideAdds async equivalents of combination approval helpers and refactors label formatting into a shared helper, along with pytest async integration tests and approved outputs. Sequence diagram for async combination approvals verificationsequenceDiagram
actor PytestTest as Pytest_test_async_function
participant VerifyAsync as verify_all_combinations_async
participant PrintAsync as print_combinations_async
participant FuncUT as function_under_test
participant Verify as verify
PytestTest->>VerifyAsync: await verify_all_combinations_async(function_under_test, input_arguments, formatter, reporter, options)
VerifyAsync->>VerifyAsync: options = initialize_options(options, reporter)
VerifyAsync->>PrintAsync: await print_combinations_async(formatter, function_under_test, product(*input_arguments))
activate PrintAsync
loop for each args in parameter_combinations
PrintAsync->>FuncUT: await function_under_test(*args)
alt function_under_test raises exception
FuncUT-->>PrintAsync: exception
PrintAsync->>PrintAsync: result = exception
else function_under_test returns normally
FuncUT-->>PrintAsync: result
end
PrintAsync->>PrintAsync: approval_strings.append(formatter(args, result))
end
PrintAsync-->>VerifyAsync: text
deactivate PrintAsync
VerifyAsync->>Verify: verify(text, options)
Verify-->>VerifyAsync: None
VerifyAsync-->>PytestTest: None
%% Labeled async helper wrapper
participant VerifyLabeledAsync as verify_all_combinations_with_labeled_input_async
participant GetLabelFormatter as _get_label_formatter
PytestTest->>VerifyLabeledAsync: await verify_all_combinations_with_labeled_input_async(function_under_test, **kwargs, options)
VerifyLabeledAsync->>VerifyLabeledAsync: labels = list(kwargs.keys())
VerifyLabeledAsync->>VerifyLabeledAsync: input_arguments = [kwargs[key] for key in kwargs]
VerifyLabeledAsync->>GetLabelFormatter: _get_label_formatter(labels)
GetLabelFormatter-->>VerifyLabeledAsync: formatter
VerifyLabeledAsync->>VerifyAsync: await verify_all_combinations_async(function_under_test, input_arguments, formatter, None, options=options)
Class diagram for combination approvals async helpers and label formatterclassDiagram
class CombinationApprovalsModule {
+_get_label_formatter(labels: List~str~) Callable
+verify_all_combinations_with_labeled_input(function_under_test: Callable, options: Optional~Options~, **kwargs: Any) None
+args_and_result_formatter(args: List~Any~, result: int) str
+print_combinations_async(formatter: Optional~Callable~, function_under_test: Callable, parameter_combinations: CombinationsOfParameters) str
+verify_all_combinations_async(function_under_test: Callable, input_arguments: VariationForEachParameter, formatter: Optional~Callable~, reporter: Optional~ReporterForTesting~, options: Optional~Options~) None
+verify_all_combinations_with_labeled_input_async(function_under_test: Callable, options: Optional~Options~, **kwargs: Any) None
}
class FormatterFunction {
<<function>>
+__call__(inputs: Sequence~Any~, output: Any) str
}
class AsyncFormatterFunction {
<<function>>
+__call__(args: List~Any~, result: Any) str
}
class FunctionUnderTestSync {
<<function>>
+__call__(*args: Any) Any
}
class FunctionUnderTestAsync {
<<coroutine>>
+__call__(*args: Any) Any
}
class Options {
}
class ReporterForTesting {
}
class CombinationsOfParameters {
<<iterator>>
+__iter__() Iterator~List~Any~~
}
class VariationForEachParameter {
<<iterable>>
}
CombinationApprovalsModule ..> FormatterFunction : uses
CombinationApprovalsModule ..> AsyncFormatterFunction : uses
CombinationApprovalsModule ..> FunctionUnderTestSync : uses
CombinationApprovalsModule ..> FunctionUnderTestAsync : uses
CombinationApprovalsModule ..> Options : uses
CombinationApprovalsModule ..> ReporterForTesting : uses
CombinationApprovalsModule ..> CombinationsOfParameters : uses
CombinationApprovalsModule ..> VariationForEachParameter : uses
CombinationApprovalsModule "1" o-- "many" FormatterFunction : creates_via__get_label_formatter
CombinationApprovalsModule "1" ..> "1" AsyncFormatterFunction : default_args_and_result_formatter
FormatterFunction <|.. AsyncFormatterFunction
FunctionUnderTestSync <|.. FunctionUnderTestAsync
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #114