Author: Amaury Forgeot d'Arc <[email protected]>
Branch: more-rposix
Changeset: r77007:03368f9d0d4c
Date: 2015-04-24 23:18 +0200
http://bitbucket.org/pypy/pypy/changeset/03368f9d0d4c/

Log:    Move tests from ll_os_stat to rposix_stat

diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -39,24 +39,6 @@
         data = rposix.getlogin()
         assert data == expected
 
-    def test_statvfs(self):
-        if not hasattr(os, 'statvfs'):
-            py.test.skip('posix specific function')
-        try:
-            os.statvfs('.')
-        except OSError, e:
-            py.test.skip("the underlying os.statvfs() failed: %s" % e)
-        rposix_stat.statvfs('.')
-
-    def test_fstatvfs(self):
-        if not hasattr(os, 'fstatvfs'):
-            py.test.skip('posix specific function')
-        try:
-            os.fstatvfs(0)
-        except OSError, e:
-            py.test.skip("the underlying os.fstatvfs() failed: %s" % e)
-        rposix_stat.fstatvfs(0)
-
     def test_utimes(self):
         if os.name != 'nt':
             py.test.skip('Windows specific feature')
diff --git a/rpython/rlib/test/test_rposix_stat.py 
b/rpython/rlib/test/test_rposix_stat.py
new file mode 100644
--- /dev/null
+++ b/rpython/rlib/test/test_rposix_stat.py
@@ -0,0 +1,56 @@
+import os, sys
+import py
+from rpython.rlib import rposix_stat
+from rpython.tool.udir import udir
+from rpython.rtyper.test.test_llinterp import interpret
+
+class TestPosixStatFunctions:
+    def test_has_all_fields(self):
+        assert rposix_stat.STAT_FIELDS == rposix_stat.ALL_STAT_FIELDS[:13]
+
+    def test_stat(self):
+        def check(f):
+            # msec resolution, +- rounding error
+            expected = int(os.stat(f).st_mtime*1000)
+            assert abs(int(rposix_stat.stat(f).st_mtime*1000) - expected) < 2
+            assert abs(int(rposix_stat.stat(unicode(f)).st_mtime*1000) - 
expected) < 2
+
+        if sys.platform == 'win32':
+            check('c:/')
+            check(os.environ['TEMP'])
+        else:
+            check('/')
+            check('/tmp')
+        check(sys.executable)
+
+    def test_fstat(self):
+        stat = rposix_stat.fstat(0) # stdout
+        assert stat.st_mode != 0
+
+    def test_stat_large_number(self):
+        if sys.version_info < (2, 7):
+            py.test.skip('requires Python 2.7')
+        fname = udir.join('test_stat_large_number.txt')
+        fname.ensure()
+        t1 = 5000000000.0
+        os.utime(str(fname), (t1, t1))
+        assert rposix_stat.stat(str(fname)).st_mtime == t1
+
+    def test_statvfs(self):
+        if not hasattr(os, 'statvfs'):
+            py.test.skip('posix specific function')
+        try:
+            os.statvfs('.')
+        except OSError, e:
+            py.test.skip("the underlying os.statvfs() failed: %s" % e)
+        rposix_stat.statvfs('.')
+
+    def test_fstatvfs(self):
+        if not hasattr(os, 'fstatvfs'):
+            py.test.skip('posix specific function')
+        try:
+            os.fstatvfs(0)
+        except OSError, e:
+            py.test.skip("the underlying os.fstatvfs() failed: %s" % e)
+        rposix_stat.fstatvfs(0)
+
diff --git a/rpython/rtyper/module/test/test_ll_os_stat.py 
b/rpython/rtyper/module/test/test_ll_os_stat.py
deleted file mode 100644
--- a/rpython/rtyper/module/test/test_ll_os_stat.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from rpython.rtyper.module import ll_os_stat, ll_os
-from rpython.tool.udir import udir
-import sys, os
-import py
-
-
-class TestLinuxImplementation:
-    def setup_class(cls):
-        if not sys.platform.startswith('linux'):
-            py.test.skip("linux specific tests")
-
-    def test_has_all_fields(self):
-        assert ll_os_stat.STAT_FIELDS == ll_os_stat.ALL_STAT_FIELDS[:13]
-
-
-class TestWin32Implementation:
-    def setup_class(cls):
-        if sys.platform != 'win32':
-            py.test.skip("win32 specific tests")
-
-    def test_stat(self):
-        stat = ll_os_stat.make_win32_stat_impl('stat', ll_os.StringTraits())
-        wstat = ll_os_stat.make_win32_stat_impl('stat', ll_os.UnicodeTraits())
-        def check(f):
-            # msec resolution, +- rounding error
-            expected = int(os.stat(f).st_mtime*1000)
-            assert abs(int(stat(f).st_mtime*1000) - expected) < 2
-            assert abs(int(wstat(unicode(f)).st_mtime*1000) - expected) < 2
-
-        check('c:/')
-        check(os.environ['TEMP'])
-        check(sys.executable)
-
-    def test_fstat(self):
-        fstat = ll_os_stat.make_win32_stat_impl('fstat', ll_os.StringTraits())
-        stat = fstat(0) # stdout
-        assert stat.st_mode != 0
-
-    def test_stat_large_number(self):
-        if sys.version_info < (2, 7):
-            py.test.skip('requires Python 2.7')
-        fname = udir.join('test_stat_large_number.txt')
-        fname.ensure()
-        t1 = 5000000000.0
-        os.utime(str(fname), (t1, t1))
-        stat = ll_os_stat.make_win32_stat_impl('stat', ll_os.StringTraits())
-        assert stat(str(fname)).st_mtime == t1
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to