Commits

holger krekel committed 7306d96

fix issue2 - test use correct ModuleType on Jython

Comments (0)

Files changed (5)

+1.3.dev
+----------------------------------------
+
+- fix issue2 - adapt tests on Jython
+
 1.2
 ----------------------------------------
 
 import sys
 from types import ModuleType
 
-__version__ = '1.2'
+__version__ = '1.3.dev'
 
 def initpkg(pkgname, exportdefs, attr=dict()):
     """ initialize given package from the export definitions. """
         description=
         'apipkg: namespace control and lazy-import mechanism',
         long_description = open('README.txt').read(),
-        version='1.2',
+        version='1.3.dev',
         url='http://bitbucket.org/hpk42/apipkg',
         license='MIT License',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
 #
 # test support for importing modules
 #
+ModuleType = py.std.types.ModuleType
 
 class TestRealModule:
 
     return ns
 
 def test_initpkg_replaces_sysmodules(monkeypatch):
-    mod = type(sys)('hello')
+    mod = ModuleType('hello')
     monkeypatch.setitem(sys.modules, 'hello', mod)
     apipkg.initpkg('hello', {'x': 'os.path:abspath'})
     newmod = sys.modules['hello']
     assert newmod.x == py.std.os.path.abspath
 
 def test_initpkg_transfers_attrs(monkeypatch):
-    mod = type(sys)('hello')
+    mod = ModuleType('hello')
     mod.__version__ = 10
     mod.__file__ = "hello.py"
     mod.__loader__ = "loader"
     assert newmod.__doc__ == mod.__doc__
 
 def test_initpkg_nodoc(monkeypatch):
-    mod = type(sys)('hello')
+    mod = ModuleType('hello')
     mod.__file__ = "hello.py"
     monkeypatch.setitem(sys.modules, 'hello', mod)
     apipkg.initpkg('hello', {})
     assert not newmod.__doc__
 
 def test_initpkg_overwrite_doc(monkeypatch):
-    hello = type(sys)('hello')
+    hello = ModuleType('hello')
     hello.__doc__ = "this is the documentation"
     monkeypatch.setitem(sys.modules, 'hello', hello)
     apipkg.initpkg('hello', {"__doc__": "sys:__doc__"})
     assert newhello.__doc__ == sys.__doc__
 
 def test_initpkg_not_transfers_not_existing_attrs(monkeypatch):
-    mod = type(sys)('hello')
+    mod = ModuleType('hello')
     mod.__file__ = "hello.py"
     monkeypatch.setitem(sys.modules, 'hello', mod)
     apipkg.initpkg('hello', {})
     assert not hasattr(newmod, '__path__')
 
 def test_initpkg_defaults(monkeypatch):
-    mod = type(sys)('hello')
+    mod = ModuleType('hello')
     monkeypatch.setitem(sys.modules, 'hello', mod)
     apipkg.initpkg('hello', {})
     newmod = sys.modules['hello']
 
 [testenv]
 commands=py.test --junitxml={envlogdir}/junit-{envname}.xml []
-deps= pytest
+deps=pytest
+
+[testenv:jython]
+commands=py.test-jython --junitxml={envlogdir}/junit-{envname}.xml []