add a --version option to print the pylib version
--HG-- branch : 1.0.x
This commit is contained in:
		
							parent
							
								
									7b906ca763
								
							
						
					
					
						commit
						d702f4da14
					
				|  | @ -11,14 +11,16 @@ Changes between 1.0.0 and 1.0.1 | ||||||
|   was adapted and somewhat unified between windows and linux  |   was adapted and somewhat unified between windows and linux  | ||||||
| 
 | 
 | ||||||
| * fix issue #27: better reporting on non-collectable items given on commandline  | * fix issue #27: better reporting on non-collectable items given on commandline  | ||||||
|   (e.g. pyc files)  |   (e.g. pyc files) | ||||||
|  | 
 | ||||||
|  | * fix issue #33: added --version flag (thanks Benjamin Peterson)  | ||||||
| 
 | 
 | ||||||
| * "Test" prefixed classes are *not* collected by default anymore if they  | * "Test" prefixed classes are *not* collected by default anymore if they  | ||||||
|   have an __init__ method  |   have an __init__ method  | ||||||
| 
 | 
 | ||||||
| * monkeypatch setenv() now accepts a "prepend" parameter | * monkeypatch setenv() now accepts a "prepend" parameter | ||||||
| 
 | 
 | ||||||
| * terser reporting of collection error tracebacks | * improved reporting of collection error tracebacks | ||||||
| 
 | 
 | ||||||
| * simplified multicall mechanism and plugin architecture,  | * simplified multicall mechanism and plugin architecture,  | ||||||
|   renamed some internal methods and argnames  |   renamed some internal methods and argnames  | ||||||
|  |  | ||||||
|  | @ -1,5 +1,6 @@ | ||||||
| """ default hooks and general py.test options. """  | """ default hooks and general py.test options. """  | ||||||
| 
 | 
 | ||||||
|  | import sys | ||||||
| import py | import py | ||||||
| 
 | 
 | ||||||
| def pytest_pyfunc_call(__multicall__, pyfuncitem): | def pytest_pyfunc_call(__multicall__, pyfuncitem): | ||||||
|  | @ -90,10 +91,17 @@ def pytest_addoption(parser): | ||||||
|                help="shortcut for '--dist=load --tx=NUM*popen'") |                help="shortcut for '--dist=load --tx=NUM*popen'") | ||||||
|     group.addoption('--rsyncdir', action="append", default=[], metavar="dir1",  |     group.addoption('--rsyncdir', action="append", default=[], metavar="dir1",  | ||||||
|                help="add directory for rsyncing to remote tx nodes.") |                help="add directory for rsyncing to remote tx nodes.") | ||||||
|  |     group.addoption('--version', action="store_true", | ||||||
|  |                     help="display version information") | ||||||
| 
 | 
 | ||||||
| def pytest_configure(config): | def pytest_configure(config): | ||||||
|     fixoptions(config) |     fixoptions(config) | ||||||
|     setsession(config) |     setsession(config) | ||||||
|  |     if config.option.version: | ||||||
|  |         p = py.path.local(py.__file__).dirpath() | ||||||
|  |         print "This is py.test version %s, imported from %s" % ( | ||||||
|  |             py.__version__, p) | ||||||
|  |         sys.exit(0) | ||||||
|     #xxxloadplugins(config) |     #xxxloadplugins(config) | ||||||
| 
 | 
 | ||||||
| def fixoptions(config): | def fixoptions(config): | ||||||
|  |  | ||||||
|  | @ -3,6 +3,14 @@ import py | ||||||
| EXPECTTIMEOUT=10.0 | EXPECTTIMEOUT=10.0 | ||||||
| 
 | 
 | ||||||
| class TestGeneralUsage: | class TestGeneralUsage: | ||||||
|  |     def test_version(self, testdir): | ||||||
|  |         assert py.version == py.__version__  | ||||||
|  |         result = testdir.runpytest("--version") | ||||||
|  |         assert result.ret == 0 | ||||||
|  |         p = py.path.local(py.__file__).dirpath() | ||||||
|  |         assert result.stderr.fnmatch_lines([ | ||||||
|  |             '*py.test*%s*, imported from: %s*' % (py.version, p) | ||||||
|  |         ]) | ||||||
|     def test_config_error(self, testdir): |     def test_config_error(self, testdir): | ||||||
|         testdir.makeconftest(""" |         testdir.makeconftest(""" | ||||||
|             def pytest_configure(config): |             def pytest_configure(config): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue