Commits

Maciej Fijalkowski  committed 5c7390b

fix few things

  • Participants
  • Parent commits a317cb5
  • Branches kill-someobject

Comments (0)

Files changed (2)

File pypy/translator/c/test/test_extfunc.py

         return fd
 
     f1 = compile(does_stuff, [])
-    py.test.raises(OSError, f1)
+    f1(expected_exception_name='OSError')
     assert not os.path.exists(tmpfile)
 
 def test_open_read_write_seek_close():
     filename = str(py.path.local(__file__))
     def call_access(path, mode):
         return os.access(path, mode)
-    f = compile(call_access, [annmodel.s_Str0, int])
+    f = compile(call_access, [str, int])
     for mode in os.R_OK, os.W_OK, os.X_OK, (os.R_OK | os.W_OK | os.X_OK):
         assert f(filename, mode) == os.access(filename, mode)
 
         res = (st[0], st.st_ino, st.st_ctime)
         if has_blksize: res += (st.st_blksize,)
         if has_blocks: res += (st.st_blocks,)
-        return res
+        return str(res)
     f = compile(call_stat, [])
-    res = f()
+    res = eval(f())
     assert res[0] == os.stat(filename).st_mode
     assert res[1] == os.stat(filename).st_ino
     st_ctime = res[2]
     if isinstance(st_ctime, float):
-        assert st_ctime == os.stat(filename).st_ctime
+        assert (st_ctime - os.stat(filename).st_ctime) < 0.1
     else:
         assert st_ctime == int(os.stat(filename).st_ctime)
     if has_blksize:
         fd = os.open(filename, os.O_RDONLY, 0777)
         st = os.fstat(fd)
         os.close(fd)
-        return (st.st_mode, st[1], st.st_mtime)
+        return str((st.st_mode, st[1], st.st_mtime))
     f = compile(call_fstat, [])
     osstat = os.stat(filename)
-    st_mode, st_ino, st_mtime = f()
+    st_mode, st_ino, st_mtime = eval(f())
     assert st_mode  == osstat.st_mode
     if sys.platform != 'win32':
         assert st_ino  == osstat.st_ino
     if isinstance(st_mtime, float):
-        assert st_mtime == osstat.st_mtime
+        assert (st_mtime - osstat.st_mtime) < 0.1
     else:
         assert st_mtime == int(osstat.st_mtime)
 
 def test_system():
     def does_stuff(cmd):
         return os.system(cmd)
-    f1 = compile(does_stuff, [annmodel.s_Str0])
+    f1 = compile(does_stuff, [str])
     res = f1("echo hello")
     assert res == 0
 
 def test_chdir():
     def does_stuff(path):
         os.chdir(path)
-    f1 = compile(does_stuff, [annmodel.s_Str0])
+    f1 = compile(does_stuff, [str])
     curdir = os.getcwd()
     try:
         os.chdir('..')
             os.rmdir(path)
         else:
             os.mkdir(path, 0777)
-    f1 = compile(does_stuff, [annmodel.s_Str0, bool])
+    f1 = compile(does_stuff, [str, bool])
     dirname = str(udir.join('test_mkdir_rmdir'))
     f1(dirname, False)
     assert os.path.exists(dirname) and os.path.isdir(dirname)
             return os.environ[s]
         except KeyError:
             return '--missing--'
-    func = compile(fn, [annmodel.s_Str0])
+    func = compile(fn, [str])
     os.environ.setdefault('USER', 'UNNAMED_USER')
     result = func('USER')
     assert result == os.environ['USER']
         res = os.environ.get(s)
         if res is None: res = '--missing--'
         return res
-    func = compile(fn, [annmodel.s_Str0])
+    func = compile(fn, [str])
     os.environ.setdefault('USER', 'UNNAMED_USER')
     result = func('USER')
     assert result == os.environ['USER']
         os.environ[s] = t3
         os.environ[s] = t4
         os.environ[s] = t5
-    func = compile(fn, [annmodel.s_Str0] * 6)
+    func = compile(fn, [str] * 6)
     func('PYPY_TEST_DICTLIKE_ENVIRON', 'a', 'b', 'c', 'FOOBAR', '42',
          expected_extra_mallocs = (2, 3, 4))   # at least two, less than 5
     assert _real_getenv('PYPY_TEST_DICTLIKE_ENVIRON') == '42'
             else:
                 raise Exception("should have raised!")
             # os.environ[s5] stays
-    func = compile(fn, [annmodel.s_Str0] * 5)
+    func = compile(fn, [str] * 5)
     if hasattr(__import__(os.name), 'unsetenv'):
         expected_extra_mallocs = range(2, 10)
         # at least 2, less than 10: memory for s1, s2, s3, s4 should be freed
             raise AssertionError("should have failed!")
         result = os.listdir(s)
         return '/'.join(result)
-    func = compile(mylistdir, [annmodel.s_Str0])
+    func = compile(mylistdir, [str])
     for testdir in [str(udir), os.curdir]:
         result = func(testdir)
         result = result.split('/')
             os.execv(l[0], l)
 
         func = compile(does_stuff, [])
-        py.test.raises(OSError, "func()")
+        func(expected_exception_name='OSError')
 
     def test_execve():
         filename = str(udir.join('test_execve.txt'))

File pypy/translator/c/test/test_genc.py

         return "%d:%d" % (intmask(v >> 32), intmask(v & signed_ffffffff))
     elif isinstance(v, float):
         return repr(v)    # extra precision than str(v)
+    elif isinstance(v, str):
+        return v + '.'
     return str(v)
 
 @specialize.argtype(0)
                 else:
                     args += (float(a),)
             else:
-                args += (a,)
+                args += (a[:-1],)
         res = fn(*args)
         print "THE RESULT IS:", llrepr_out(res), ";"
         return 0