call path.read(), add tests, add news fragment
This commit is contained in:
		
							parent
							
								
									b29a9711c4
								
							
						
					
					
						commit
						eaf38c7239
					
				
							
								
								
									
										1
									
								
								AUTHORS
								
								
								
								
							
							
						
						
									
										1
									
								
								AUTHORS
								
								
								
								
							|  | @ -82,6 +82,7 @@ Jason R. Coombs | ||||||
| Javier Domingo Cansino | Javier Domingo Cansino | ||||||
| Javier Romero | Javier Romero | ||||||
| Jeff Widman | Jeff Widman | ||||||
|  | John Eddie Ayson | ||||||
| John Towler | John Towler | ||||||
| Jon Sonesen | Jon Sonesen | ||||||
| Jonas Obrist | Jonas Obrist | ||||||
|  |  | ||||||
|  | @ -59,8 +59,7 @@ def pytest_collect_file(path, parent): | ||||||
| def _is_setup_py(config, path, parent): | def _is_setup_py(config, path, parent): | ||||||
|     if path.basename != "setup.py": |     if path.basename != "setup.py": | ||||||
|         return False |         return False | ||||||
|     with open(path.strpath, 'r') as f: |     contents = path.read() | ||||||
|         contents = f.read() |  | ||||||
|     return 'setuptools' in contents or 'distutils' in contents |     return 'setuptools' in contents or 'distutils' in contents | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1 @@ | ||||||
|  | Implement feature to skip valid setup.py files when ran with --doctest-modules | ||||||
|  | @ -561,6 +561,34 @@ class TestDoctests(object): | ||||||
|         reportinfo = items[0].reportinfo() |         reportinfo = items[0].reportinfo() | ||||||
|         assert reportinfo[1] == 1 |         assert reportinfo[1] == 1 | ||||||
| 
 | 
 | ||||||
|  |     def test_valid_setup_py(self, testdir): | ||||||
|  |         ''' | ||||||
|  |         Test to make sure that pytest ignores valid setup.py files when ran | ||||||
|  |         with --doctest-modules | ||||||
|  |         ''' | ||||||
|  |         p = testdir.makepyfile(setup=""" | ||||||
|  |             from setuptools import setup, find_packages | ||||||
|  |             setup(name='sample', | ||||||
|  |                   version='0.0', | ||||||
|  |                   description='description', | ||||||
|  |                   packages=find_packages() | ||||||
|  |             ) | ||||||
|  |         """) | ||||||
|  |         result = testdir.runpytest(p, '--doctest-modules') | ||||||
|  |         result.stdout.fnmatch_lines(['*collected 0 items*']) | ||||||
|  | 
 | ||||||
|  |     def test_invalid_setup_py(self, testdir): | ||||||
|  |         ''' | ||||||
|  |         Test to make sure that pytest reads setup.py files that are not used | ||||||
|  |         for python packages when ran with --doctest-modules | ||||||
|  |         ''' | ||||||
|  |         p = testdir.makepyfile(setup=""" | ||||||
|  |             def test_foo(): | ||||||
|  |                 return 'bar' | ||||||
|  |         """) | ||||||
|  |         result = testdir.runpytest(p, '--doctest-modules') | ||||||
|  |         result.stdout.fnmatch_lines(['*collected 1 item*']) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class TestLiterals(object): | class TestLiterals(object): | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue