fix windows32 issues, introduce a simplistic path.samefile for it, fix tests
--HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									c02719f44c
								
							
						
					
					
						commit
						30710a9cd6
					
				|  | @ -300,6 +300,10 @@ newline will be removed from the end of each line. """ | |||
|             else: | ||||
|                 res.sort() | ||||
| 
 | ||||
|     def samefile(self, other): | ||||
|         """ return True if other refers to the same stat object as self. """ | ||||
|         return self.strpath == str(other) | ||||
| 
 | ||||
| class FNMatcher: | ||||
|     def __init__(self, pattern): | ||||
|         self.pattern = pattern | ||||
|  |  | |||
|  | @ -70,7 +70,7 @@ class PosixPath(common.PathBase): | |||
| 
 | ||||
|     def samefile(self, other): | ||||
|         """ return True if other refers to the same stat object as self. """ | ||||
|         return py.std.os.path.samefile(str(self), str(other)) | ||||
|         return py.error.checked_call(os.path.samefile, str(self), str(other)) | ||||
| 
 | ||||
| def getuserid(user): | ||||
|     import pwd | ||||
|  |  | |||
							
								
								
									
										11
									
								
								conftest.py
								
								
								
								
							
							
						
						
									
										11
									
								
								conftest.py
								
								
								
								
							|  | @ -1,6 +1,15 @@ | |||
| import py | ||||
| 
 | ||||
| pytest_plugins = '_pytest doctest pytester'.split() | ||||
| 
 | ||||
| rsyncdirs = ['conftest.py', 'py', 'doc', 'testing'] | ||||
| 
 | ||||
| rsyncdirs = ['conftest.py', 'bin', 'py', 'doc', 'testing'] | ||||
| try: | ||||
|     import execnet | ||||
| except ImportError: | ||||
|     pass | ||||
| else: | ||||
|     rsyncdirs.append(str(py.path.local(execnet.__file__).dirpath())) | ||||
| 
 | ||||
| import py | ||||
| def pytest_addoption(parser): | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ def test_unicode_encoding(): | |||
|         l = [] | ||||
|         tw = py.io.TerminalWriter(l.append, encoding=encoding) | ||||
|         tw.line(msg) | ||||
|         assert l[0] == msg.encode(encoding) | ||||
|         assert l[0].strip() == msg.encode(encoding) | ||||
| 
 | ||||
| class BaseTests: | ||||
|     def test_line(self):     | ||||
|  |  | |||
|  | @ -118,7 +118,7 @@ class TestLogConsumer: | |||
| 
 | ||||
|     def test_log_file(self): | ||||
|         customlog = tempdir.join('log.out') | ||||
|         py.log.setconsumer("default", open(str(customlog), 'w', buffering=1)) | ||||
|         py.log.setconsumer("default", open(str(customlog), 'w', buffering=0)) | ||||
|         py.log.Producer("default")("hello world #1")  | ||||
|         assert customlog.readlines() == ['[default] hello world #1\n'] | ||||
| 
 | ||||
|  |  | |||
|  | @ -368,14 +368,19 @@ def test_homedir(): | |||
|     homedir = py.path.local._gethomedir() | ||||
|     assert homedir.check(dir=1) | ||||
| 
 | ||||
| def test_samefile(tmpdir): | ||||
|     assert tmpdir.samefile(tmpdir) | ||||
|     p = tmpdir.ensure("hello") | ||||
|     assert p.samefile(p)  | ||||
| 
 | ||||
| class TestWINLocalPath: | ||||
|     pytestmark = py.test.mark.skipif("sys.platform != 'win32'") | ||||
| 
 | ||||
|     def test_owner_group_not_implemented(self): | ||||
|     def test_owner_group_not_implemented(self, path1): | ||||
|         py.test.raises(NotImplementedError, "path1.stat().owner") | ||||
|         py.test.raises(NotImplementedError, "path1.stat().group") | ||||
| 
 | ||||
|     def test_chmod_simple_int(self): | ||||
|     def test_chmod_simple_int(self, path1): | ||||
|         py.builtin.print_("path1 is", path1) | ||||
|         mode = path1.stat().mode | ||||
|         # Ensure that we actually change the mode to something different. | ||||
|  | @ -388,18 +393,18 @@ class TestWINLocalPath: | |||
|             path1.chmod(mode) | ||||
|             assert path1.stat().mode == mode | ||||
| 
 | ||||
|     def test_path_comparison_lowercase_mixed(self): | ||||
|     def test_path_comparison_lowercase_mixed(self, path1): | ||||
|         t1 = path1.join("a_path") | ||||
|         t2 = path1.join("A_path") | ||||
|         assert t1 == t1 | ||||
|         assert t1 == t2 | ||||
|          | ||||
|     def test_relto_with_mixed_case(self): | ||||
|     def test_relto_with_mixed_case(self, path1): | ||||
|         t1 = path1.join("a_path", "fiLe") | ||||
|         t2 = path1.join("A_path") | ||||
|         assert t1.relto(t2) == "fiLe" | ||||
| 
 | ||||
|     def test_allow_unix_style_paths(self): | ||||
|     def test_allow_unix_style_paths(self, path1): | ||||
|         t1 = path1.join('a_path') | ||||
|         assert t1 == str(path1) + '\\a_path' | ||||
|         t1 = path1.join('a_path/') | ||||
|  | @ -407,7 +412,7 @@ class TestWINLocalPath: | |||
|         t1 = path1.join('dir/a_path') | ||||
|         assert t1 == str(path1) + '\\dir\\a_path' | ||||
| 
 | ||||
|     def test_sysfind_in_currentdir(self): | ||||
|     def test_sysfind_in_currentdir(self, path1): | ||||
|         cmd = py.path.local.sysfind('cmd') | ||||
|         root = cmd.new(dirname='', basename='') # c:\ in most installations | ||||
|         old = root.chdir() | ||||
|  | @ -420,11 +425,6 @@ class TestWINLocalPath: | |||
| class TestPOSIXLocalPath: | ||||
|     pytestmark = py.test.mark.skipif("sys.platform == 'win32'") | ||||
| 
 | ||||
|     def test_samefile(self, tmpdir): | ||||
|         assert tmpdir.samefile(tmpdir) | ||||
|         p = tmpdir.ensure("hello") | ||||
|         assert p.samefile(p)  | ||||
| 
 | ||||
|     def test_hardlink(self, tmpdir): | ||||
|         linkpath = tmpdir.join('test') | ||||
|         filepath = tmpdir.join('file') | ||||
|  |  | |||
|  | @ -8,7 +8,8 @@ def checksubpackage(name): | |||
|         keys = dir(obj) | ||||
|         assert len(keys) > 0 | ||||
|         print (obj.__map__) | ||||
|         assert getattr(obj, '__map__')  == {} | ||||
|         for name in obj.__map__: | ||||
|             assert hasattr(obj, name), (obj, name) | ||||
| 
 | ||||
| def test_dir(): | ||||
|     for name in dir(py): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue