run doctests in .txt/.rst files directly specified on command line irrespective of "test*.txt" pattern.
This commit is contained in:
		
							parent
							
								
									fb102a2ddb
								
							
						
					
					
						commit
						acd286f82f
					
				|  | @ -19,7 +19,8 @@ def pytest_collect_file(path, parent): | ||||||
|     if path.ext == ".py": |     if path.ext == ".py": | ||||||
|         if config.option.doctestmodules: |         if config.option.doctestmodules: | ||||||
|             return DoctestModule(path, parent) |             return DoctestModule(path, parent) | ||||||
|     elif path.check(fnmatch=config.getvalue("doctestglob")): |     elif (path.ext in ('.txt', '.rst') and parent.session.isinitpath(path)) or \ | ||||||
|  |         path.check(fnmatch=config.getvalue("doctestglob")): | ||||||
|         return DoctestTextfile(path, parent) |         return DoctestTextfile(path, parent) | ||||||
| 
 | 
 | ||||||
| class ReprFailDoctest(TerminalRepr): | class ReprFailDoctest(TerminalRepr): | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ py.test: no-boilerplate testing with Python | ||||||
| 
 | 
 | ||||||
| .. note:: | .. note:: | ||||||
|     version 2.0 introduces ``pytest`` as the main Python import name |     version 2.0 introduces ``pytest`` as the main Python import name | ||||||
|     but for compatibility reasons you may continue to use ``py.test`` |     but for compatibility reasons you can continue to use ``py.test`` | ||||||
|     in your test code. |     in your test code. | ||||||
| 
 | 
 | ||||||
| Welcome to ``py.test`` documentation: | Welcome to ``py.test`` documentation: | ||||||
|  |  | ||||||
|  | @ -1,12 +1,10 @@ | ||||||
| from _pytest.doctest import DoctestModule, DoctestTextfile | from _pytest.doctest import DoctestModule, DoctestTextfile | ||||||
| import py | import py | ||||||
| 
 | 
 | ||||||
| pytest_plugins = ["pytest_doctest"] |  | ||||||
| 
 |  | ||||||
| class TestDoctests: | class TestDoctests: | ||||||
| 
 | 
 | ||||||
|     def test_collect_testtextfile(self, testdir): |     def test_collect_testtextfile(self, testdir): | ||||||
|         testdir.maketxtfile(whatever="") |         w = testdir.maketxtfile(whatever="") | ||||||
|         checkfile = testdir.maketxtfile(test_something=""" |         checkfile = testdir.maketxtfile(test_something=""" | ||||||
|             alskdjalsdk |             alskdjalsdk | ||||||
|             >>> i = 5 |             >>> i = 5 | ||||||
|  | @ -18,6 +16,8 @@ class TestDoctests: | ||||||
|             items, reprec = testdir.inline_genitems(x) |             items, reprec = testdir.inline_genitems(x) | ||||||
|             assert len(items) == 1 |             assert len(items) == 1 | ||||||
|             assert isinstance(items[0], DoctestTextfile) |             assert isinstance(items[0], DoctestTextfile) | ||||||
|  |         items, reprec = testdir.inline_genitems(w) | ||||||
|  |         assert len(items) == 1 | ||||||
| 
 | 
 | ||||||
|     def test_collect_module(self, testdir): |     def test_collect_module(self, testdir): | ||||||
|         path = testdir.makepyfile(whatever="#") |         path = testdir.makepyfile(whatever="#") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue