-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from Erotemic/dev/0.15.10
Dev/0.15.10
- Loading branch information
Showing
9 changed files
with
164 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ name: Tests | |
on: | ||
push: | ||
pull_request: | ||
branches: [ master ] | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
|
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,18 @@ | ||
""" | ||
CommandLine: | ||
xdoctest ~/code/xdoctest/dev/demo_dynamic_analysis.py --analysis=auto | ||
xdoctest ~/code/xdoctest/dev/demo_dynamic_analysis.py --analysis=dynamic | ||
xdoctest ~/code/xdoctest/dev/demo_dynamic_analysis.py --xdoc-force-dynamic | ||
""" | ||
|
||
|
||
def func() -> None: | ||
r''' Dynamic doctest | ||
>>> %s | ||
%s | ||
''' | ||
return | ||
|
||
func.__doc__ %= ('print(1)', '1') |
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,66 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
demo_usage_with_logger.py | ||
Script to demo a workaround to [Issue111]_. | ||
CommandLine: | ||
# Run with xdoctest runner | ||
xdoctest ~/code/xdoctest/dev/demo_usage_with_logger.py | ||
# Run with pytest runner | ||
pytest -s --xdoctest --xdoctest-verbose=3 ~/code/xdoctest/dev/demo_usage_with_logger.py | ||
# Run with builtin main | ||
python ~/code/xdoctest/dev/demo_usage_with_logger.py | ||
References: | ||
.. [Issue111] https://github.com/Erotemic/xdoctest/issues/111 | ||
""" | ||
import logging | ||
import sys | ||
|
||
|
||
class StreamHandler2(logging.StreamHandler): | ||
def __init__(self, _getstream=None): | ||
""" | ||
Initialize the handler. | ||
If stream is not specified, sys.stderr is used. | ||
""" | ||
logging.Handler.__init__(self) | ||
if _getstream is None: | ||
_getstream = lambda: sys.stderr # NOQA | ||
self._getstream = _getstream | ||
self.__class__.stream = property(lambda self: self._getstream()) | ||
|
||
def setStream(self, stream): | ||
raise NotImplementedError | ||
|
||
|
||
handler = StreamHandler2(lambda: sys.stdout) | ||
|
||
_log = logging.getLogger('mylog') | ||
_log.setLevel(logging.INFO) | ||
_log.addHandler(handler) | ||
|
||
_log.info('hello') | ||
_log.info('hello hello') | ||
|
||
|
||
def func_with_doctest(): | ||
""" | ||
Example: | ||
>>> _log.info('greetings from my doctest') | ||
greetings from my doctest | ||
""" | ||
|
||
|
||
def main(): | ||
import xdoctest | ||
xdoctest.doctest_callable(func_with_doctest) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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