generated from tophat/new-project-kit
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support snapshots in doc tests (#525)
- Loading branch information
Showing
6 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# name: DocTestClass | ||
DocTestClass( | ||
obj_attr='test class attr', | ||
) | ||
# --- | ||
# name: DocTestClass.1 | ||
DocTestClass( | ||
obj_attr='test class attr', | ||
) | ||
# --- | ||
# name: DocTestClass.NestedDocTestClass | ||
NestedDocTestClass( | ||
nested_obj_attr='nested doc test class attr', | ||
) | ||
# --- | ||
# name: DocTestClass.NestedDocTestClass.doctest_method | ||
'nested doc test method return value' | ||
# --- | ||
# name: DocTestClass.doctest_method | ||
'doc test method return value' | ||
# --- | ||
# name: doctest_fn | ||
'doc test fn return value' | ||
# --- | ||
# name: test_doctest.txt | ||
'There must be a break after every snapshot assertion' | ||
# --- | ||
# name: test_doctest.txt.1 | ||
'constant value' | ||
# --- | ||
# name: test_doctest.txt.2 | ||
set({ | ||
1, | ||
2, | ||
3, | ||
}) | ||
# --- |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
def doctest_fn(): | ||
"""a doctest in a function docstring | ||
>>> doctest_fn() == getfixture('snapshot') | ||
True | ||
""" | ||
return "doc test fn return value" | ||
|
||
|
||
class DocTestClass: | ||
""" | ||
>>> DocTestClass() == getfixture('snapshot') | ||
True | ||
a doctest in a class docstring | ||
>>> DocTestClass() == getfixture('snapshot') | ||
True | ||
""" | ||
|
||
obj_attr = "test class attr" | ||
|
||
def doctest_method(self): | ||
"""a doctest in a method docstring | ||
>>> DocTestClass().doctest_method() == getfixture('snapshot') | ||
True | ||
""" | ||
return "doc test method return value" | ||
|
||
class NestedDocTestClass: | ||
"""a doctest in a nested class docstring | ||
>>> DocTestClass.NestedDocTestClass() == getfixture('snapshot') | ||
True | ||
""" | ||
|
||
nested_obj_attr = "nested doc test class attr" | ||
|
||
def doctest_method(self): | ||
"""a doctest in a nested method docstring | ||
>>> nested_obj = DocTestClass.NestedDocTestClass() | ||
>>> nested_obj.doctest_method() == getfixture('snapshot') | ||
True | ||
""" | ||
return "nested doc test method return value" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
>>> "There must be a break after every snapshot assertion" == getfixture('snapshot') | ||
True | ||
|
||
doctest x | ||
|
||
doctest y | ||
>>> y = "constant value" | ||
>>> y == getfixture('snapshot') | ||
True | ||
|
||
doctest z | ||
>>> z = {1, 2, 3} | ||
>>> z == getfixture('snapshot') | ||
True |