Skip to content
This repository was archived by the owner on Nov 25, 2023. It is now read-only.

Test errors with Jython #3

Open
Arfrever opened this issue Mar 10, 2015 · 3 comments
Open

Test errors with Jython #3

Arfrever opened this issue Mar 10, 2015 · 3 comments

Comments

@Arfrever
Copy link

$ unit2-2.7-jython -v
test_checkcache (linecache2.tests.test_linecache.LineCacheTests) ... ok
test_clearcache (linecache2.tests.test_linecache.LineCacheTests) ... ok
test_getline (linecache2.tests.test_linecache.LineCacheTests) ... ERROR
test_lazycache_already_cached (linecache2.tests.test_linecache.LineCacheTests) ... skipped 'Modules not PEP302 by default'
test_lazycache_bad_filename (linecache2.tests.test_linecache.LineCacheTests) ... ok
test_lazycache_check (linecache2.tests.test_linecache.LineCacheTests) ... ok
test_lazycache_no_globals (linecache2.tests.test_linecache.LineCacheTests) ... ERROR
test_lazycache_provide_after_failed_lookup (linecache2.tests.test_linecache.LineCacheTests) ... ok
test_lazycache_smoke (linecache2.tests.test_linecache.LineCacheTests) ... skipped 'Modules not PEP302 by default'
test_no_ending_newline (linecache2.tests.test_linecache.LineCacheTests) ... ok

======================================================================
ERROR: test_getline (linecache2.tests.test_linecache.LineCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/linecache2/linecache2/tests/test_linecache.py", line 54, in test_getline
    self.assertEqual(getline(FILENAME, 2**15), EMPTY)
  File "/tmp/linecache2/linecache2/__init__.py", line 17, in getline
    lines = getlines(filename, module_globals)
  File "/tmp/linecache2/linecache2/__init__.py", line 48, in getlines
    return updatecache(filename, module_globals)
  File "/tmp/linecache2/linecache2/__init__.py", line 93, in updatecache
    stat = os.stat(fullname)
  File "/tmp/linecache2/linecache2/__init__.py", line 93, in updatecache
    stat = os.stat(fullname)
  File "/tmp/linecache2/linecache2/__init__.py", line 190, in _tokenize_open
    encoding, lines = _detect_encoding(buffer.readline)
  File "/tmp/linecache2/linecache2/__init__.py", line 285, in _detect_encoding
    encoding = find_cookie(first)
  File "/tmp/linecache2/linecache2/__init__.py", line 249, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for '/usr/share/jython-2.7/Lib/os$py.class'

======================================================================
ERROR: test_lazycache_no_globals (linecache2.tests.test_linecache.LineCacheTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/linecache2/linecache2/tests/test_linecache.py", line 143, in test_lazycache_no_globals
    lines = linecache.getlines(FILENAME)
  File "/tmp/linecache2/linecache2/__init__.py", line 48, in getlines
    return updatecache(filename, module_globals)
  File "/tmp/linecache2/linecache2/__init__.py", line 93, in updatecache
    stat = os.stat(fullname)
  File "/tmp/linecache2/linecache2/__init__.py", line 93, in updatecache
    stat = os.stat(fullname)
  File "/tmp/linecache2/linecache2/__init__.py", line 190, in _tokenize_open
    encoding, lines = _detect_encoding(buffer.readline)
  File "/tmp/linecache2/linecache2/__init__.py", line 285, in _detect_encoding
    encoding = find_cookie(first)
  File "/tmp/linecache2/linecache2/__init__.py", line 249, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for '/usr/share/jython-2.7/Lib/os$py.class'

----------------------------------------------------------------------
Ran 10 tests in 0.477s

FAILED (errors=2, skipped=2)

Fix:

--- linecache2/tests/test_linecache.py
+++ linecache2/tests/test_linecache.py
@@ -10,6 +10,9 @@
 FILENAME = os.__file__
 if FILENAME.endswith('.pyc'):
     FILENAME = FILENAME[:-1]
+elif FILENAME.endswith('$py.class'):
+    # Jython
+    FILENAME = FILENAME[:-9] + '.py'
 NONEXISTENT_FILENAME = FILENAME + '.missing'
 INVALID_NAME = '!@$)(!@#_1'
 EMPTY = ''
@rbtcollins
Copy link
Member

Does the stdlib linecache module from master also fail for you?

@Arfrever
Copy link
Author

No.
(Jython has its own copy of standard library. Some *.py files have custom changes, but linecache.py and test_linecache.py are identical to versions in CPython 2.7.)

@rbtcollins
Copy link
Member

2.7 and 3.5 are somewhat different though... I'll poke and see if the bad code is local to linecache2, or from master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants