Commits

Jonathan Eunice committed 58fe066

now uses stuf.chainstuf; worked around PyPy bug in stuf

  • Participants
  • Parent commits 8f77ed2

Comments (0)

Files changed (4)

    and `tox <http://pypi.python.org/pypi/tox>`_. Now
    successfully packaged for, and tested against, Python 2.6, 2.7, 3.2, and 3.3.
    
+ * Options is now packaged for, and tested against, PyPy 1.9 (based on 2.7.2).
+   The underlying ``stuf`` module and ``orderedstuf`` class is not
+   certified for PyPy, and it exhibits a bug with file objects on PyPy.
+   ``options`` works around this bug, and tests fine on PyPy. Still, 
+   support for PyPy should be considered experimental. 
+   
  * Versions subsequent to 0.200 require a late-model version of ``stuf`` to
-   avoid a problem its earlier iterations had with file objects.
-   
+   avoid a problem its earlier iterations had with file objects. Versions after 0.320
+   depend on ``stuf`` for ``chainstuf``, rather than the ``otherstuf`` sidecar.
+
  * Now packaged as a package, not a set of modules. ``six`` module now required only for testing.
  
  * API for ``push()`` and ``addflat()`` cleaned up to explicitly delink those methods.

File options/core.py

 
 import sys
 
-from stuf import orderedstuf
-from otherstuf import chainstuf
+from stuf import orderedstuf, chainstuf
+# from otherstuf import chainstuf
 from options.configparser import ConfigParser
 from options.nulltype import NullType
 from options.funclike import *
     """
     
     def __init__(self, *args, **kwargs):
-        orderedstuf.__init__(self, *args, **kwargs)
+        orderedstuf.__init__(self, *args)
+        for k,v in kwargs.items():
+            self[k] = v
         self._magic = {}
+        
+        # The explicit for loop setting values from kwargs should not be necessary.
+        # orderedstuf.__init__(self, *args, **kwargs) should do the trick. And it
+        # does, on most platforms. But on PyPy, stuf(a=sys.stdout) fails in much
+        # the same way used to on Python 3. Until stuf/orderedstuf is fixed for
+        # PyPy, this workaround fixes the issue for Options.
     
     def __repr__(self):
         return "{0}({1})".format(self.__class__.__name__, attrs(self))
 
 setup(
     name='options',
-    version=verno("0.3"),
+    version=verno("0.325"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
     description='Container for flexible class, instance, and function call options',
     long_description=open('README.rst').read(),
     url='https://bitbucket.org/jeunice/options',
     packages=['options'],
-    install_requires=['stuf>=0.9.10', 'otherstuf>=0.8', 'six'],
+    install_requires=['stuf>=0.9.10', 'six'],
     tests_require = ['tox', 'pytest'],
     zip_safe = True,
     keywords='options config configuration parameters arguments',
     classifiers=linelist("""
-        Development Status :: 3 - Alpha
+        Development Status :: 4 - Beta
         Operating System :: OS Independent
         License :: OSI Approved :: BSD License
         Intended Audience :: Developers
         Programming Language :: Python :: 2.7
         Programming Language :: Python :: 3.2
         Programming Language :: Python :: 3.3
+        Programming Language :: Python :: Implementation :: CPython
+        Programming Language :: Python :: Implementation :: PyPy
         Topic :: Software Development :: Libraries :: Python Modules
     """)
 )

File test/test.py

     
     # Wish we could just do ``dict(o)`` without passing through ``items()``. But how?
 
-@pytest.mark.skipif('platform.python_implementation() == "PyPy" ')
+# @pytest.mark.skipif('platform.python_implementation() == "PyPy" ')
 def test_files():
     # The underlying stuf container used to have (<0.9.9) a problem with files
     # being assigned in a stuf() constructor. This tests that we're over that
     assert ooo.b is f3
     assert ooo.c == 12
     
-    # Test fails under PyPy. Skipped because it may be a py.test issue.
+    # Test fails under PyPy.  
     
 def test_addflat():
     class AF(object):
     
     with pytest.raises(ValueError):
         d = AF('a', 'b', 'c')  # too many values!
-    
-@pytest.mark.skipif('True')  #under construction
-def test_write(tmpdir):
-    o = Options(
-        this=1,
-        slick='slack',
-        nick='nack',
-        blik=99,
-    )
-    outname = str(tmpdir.join("test.ini").realpath())
-    assert isinstance(outname, str)
-    o.write(outname)
-
-    e = Options(
-        this=None,
-        slick=None,
-        nick=None,
-        blik=None,
-    )
-    e.read(outname)
-    assert o.this  == e.this
-    assert o.slick == e.slick
-    assert o.nick  == e.nick
-    assert o.blik  == e.blik
+#    
+#@pytest.mark.skipif('True')  #under construction
+#def test_write(tmpdir):
+#    o = Options(
+#        this=1,
+#        slick='slack',
+#        nick='nack',
+#        blik=99,
+#    )
+#    outname = str(tmpdir.join("test.ini").realpath())
+#    assert isinstance(outname, str)
+#    o.write(outname)
+#
+#    e = Options(
+#        this=None,
+#        slick=None,
+#        nick=None,
+#        blik=None,
+#    )
+#    e.read(outname)
+#    assert o.this  == e.this
+#    assert o.slick == e.slick
+#    assert o.nick  == e.nick
+#    assert o.blik  == e.blik
     
     # Need to figure out py.path.LocalPath better
     # http://doc.pylib.org/en/latest/path.html#reference-documentation