Skip to content

Commit

Permalink
. d updated markdown snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 12, 2024
1 parent 1c941ef commit c8cc18c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions approvaltests/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ def inline(self, inline_options: InlineOptions = None) -> "Options":

def add_reporter(self, additional_reporter: Reporter) -> "Options":
from approvaltests.reporters import MultiReporter

return self.with_reporter(MultiReporter(self.reporter, additional_reporter))
4 changes: 2 additions & 2 deletions approvaltests/reporters/multi_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def __init__(self, *reporters) -> None:
def report(self, received_path, approved_path):
for reporter in self.reporters:
reporter.report(received_path, approved_path)

def __str__(self):
return f"MultiReporter({', '.join([r.__class__.__name__ for r in self.reporters])})"
return f"MultiReporter({', '.join([r.__class__.__name__ for r in self.reporters])})"
2 changes: 1 addition & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ If you want to set the extension of the approval file, you can now do it through
```py
verify(content, options=Options().for_file.with_extension(".md"))
```
<sup><a href='/tests/test_options.py#L65-L67' title='Snippet source file'>snippet source</a> | <a href='#snippet-options_with_file_extension' title='Start of snippet'>anchor</a></sup>
<sup><a href='/tests/test_options.py#L67-L69' title='Snippet source file'>snippet source</a> | <a href='#snippet-options_with_file_extension' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
10 changes: 8 additions & 2 deletions tests/test_inline_approvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from approvaltests.inline.inline_options import InlineOptions
from approvaltests.inline.parse_docstring import parse_docstring
from approvaltests.reporters.report_quietly import ReportQuietly
from build.lib.approvaltests.reporters.report_with_beyond_compare import ReportWithPycharm, ReportWithBeyondCompare
from build.lib.approvaltests.reporters.report_with_beyond_compare import (
ReportWithPycharm,
ReportWithBeyondCompare,
)


def get_approved_via_doc_string():
Expand Down Expand Up @@ -181,4 +184,7 @@ def test_inline_with_additional_reporter():
hello
world
"""
verify("hello\nworld", options=(Options().inline().add_reporter(ReportWithBeyondCompare())))
verify(
"hello\nworld",
options=(Options().inline().add_reporter(ReportWithBeyondCompare())),
)
31 changes: 24 additions & 7 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,32 @@ def test_file_extensions():
# end-snippet
verify(content, options=Options().for_file.with_extension("md"))


def test_add_reporter():
# current behaviour, override
options0 = Options().with_reporter(ReportByCreatingDiffFile()).with_reporter(ReportWithPycharm())
options0 = (
Options()
.with_reporter(ReportByCreatingDiffFile())
.with_reporter(ReportWithPycharm())
)
assert type(options0.reporter) == ReportWithPycharm

# current work around, create a MultiReporter
options_multi = Options().with_reporter(MultiReporter(ReportByCreatingDiffFile(), ReportWithPycharm()))
assert str(options_multi.reporter) == 'MultiReporter(ReportByCreatingDiffFile, ReportWithPycharm)'

options_multi = Options().with_reporter(
MultiReporter(ReportByCreatingDiffFile(), ReportWithPycharm())
)
assert (
str(options_multi.reporter)
== "MultiReporter(ReportByCreatingDiffFile, ReportWithPycharm)"
)

# new behaviour, append
options0 = Options().with_reporter(ReportByCreatingDiffFile()).add_reporter(ReportWithPycharm())
assert str(options_multi.reporter) == 'MultiReporter(ReportByCreatingDiffFile, ReportWithPycharm)'
options0 = (
Options()
.with_reporter(ReportByCreatingDiffFile())
.add_reporter(ReportWithPycharm())
)
assert (
str(options_multi.reporter)
== "MultiReporter(ReportByCreatingDiffFile, ReportWithPycharm)"
)

0 comments on commit c8cc18c

Please sign in to comment.