Python doctest.testsource() Examples
The following are 11
code examples of doctest.testsource().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
doctest
, or try the search function
.
Example #1
Source File: test_doctest.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """
Example #2
Source File: test_doctest.py From BinderFilter with MIT License | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """
Example #3
Source File: test_doctest.py From oss-ftp with MIT License | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """
Example #4
Source File: test_doctest.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print(doctest.testsource(test.test_doctest, name)) # Blah blah # print(sample_func(22)) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print(doctest.testsource(test.test_doctest, name)) print('1\n2\n3') # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print(doctest.testsource(test.test_doctest, name)) print(SampleClass.a_classmethod(10)) # Expected: ## 12 print(SampleClass(0).a_classmethod(10)) # Expected: ## 12 <BLANKLINE> """
Example #5
Source File: test_doctest.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print(doctest.testsource(test.test_doctest, name)) # Blah blah # print(sample_func(22)) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print(doctest.testsource(test.test_doctest, name)) print('1\n2\n3') # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print(doctest.testsource(test.test_doctest, name)) print(SampleClass.a_classmethod(10)) # Expected: ## 12 print(SampleClass(0).a_classmethod(10)) # Expected: ## 12 <BLANKLINE> """
Example #6
Source File: test_doctest.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """
Example #7
Source File: test_doctest.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print(doctest.testsource(test.test_doctest, name)) # Blah blah # print(sample_func(22)) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print(doctest.testsource(test.test_doctest, name)) print('1\n2\n3') # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print(doctest.testsource(test.test_doctest, name)) print(SampleClass.a_classmethod(10)) # Expected: ## 12 print(SampleClass(0).a_classmethod(10)) # Expected: ## 12 <BLANKLINE> """
Example #8
Source File: test_doctest.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """
Example #9
Source File: test_doctest.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """
Example #10
Source File: test_doctest.py From android_universal with MIT License | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print(doctest.testsource(test.test_doctest, name)) # Blah blah # print(sample_func(22)) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print(doctest.testsource(test.test_doctest, name)) print('1\n2\n3') # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print(doctest.testsource(test.test_doctest, name)) print(SampleClass.a_classmethod(10)) # Expected: ## 12 print(SampleClass(0).a_classmethod(10)) # Expected: ## 12 <BLANKLINE> """
Example #11
Source File: test_doctest.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """