Example #1
0
    def test_can_xpartial_any_callable(self):
        class my_callable(object):
            def __call__(self, x):
                return "hello %s" % x

        f = xpartial(my_callable(), (X + "!"))
        assert f("x") == "hello x!"
Example #2
0
    def test_can_xpartial_any_callable(self):
        class my_callable(object):
            def __call__(self, x):
                return "hello %s" % x

        f = xpartial(my_callable(), (X + "!"))
        assert f("x") == "hello x!"
Example #3
0
 def test_should_raise_error_when_not_given_an_argument(self):
     # -- when created with a placeholder
     xf = xpartial(dummy, something=X)
     with pytest.raises(ValueError):
         xf()
Example #4
0
 def test_repr(self):
     xf = xpartial(dummy, X, 3, something=X['something'])
     assert repr(X | xf) == "X | dummy(X, 3, something=X['something'])"
Example #5
0
 def test_x_destructuring(self):
     xf = xpartial(dummy, X['name'], number=X['number'])
     d = {'name': "Fred", 'number': 42, 'something': 'else'}
     assert xf(d) == (('Fred',), {'number': 42})
Example #6
0
 def test_x_kw_placeholder(self):
     xf = xpartial(dummy, kwarg=X)
     assert xf(1) == ((), {'kwarg': 1})
Example #7
0
 def test_x_placeholder(self):
     xf = xpartial(dummy, X, 2)
     assert xf(1) == ((1, 2), {})
Example #8
0
 def test_should_behave_like_partial(self):
     xf = xpartial(dummy, 1, kwarg='kwarg')
     assert xf(2, foo='bar') == ((1, 2), {'kwarg': 'kwarg', 'foo': 'bar'})
Example #9
0
 def test_should_raise_error_when_not_given_an_argument(self):
     # -- when created with a placeholder
     xf = xpartial(dummy, something=X)
     with pytest.raises(ValueError):
         xf()
Example #10
0
 def test_repr(self):
     xf = xpartial(dummy, X, 3, something=X['something'])
     assert repr(X | xf) == "X | dummy(X, 3, something=X['something'])"
Example #11
0
 def test_x_destructuring(self):
     xf = xpartial(dummy, X['name'], number=X['number'])
     d = {'name': "Fred", 'number': 42, 'something': 'else'}
     assert xf(d) == (('Fred', ), {'number': 42})
Example #12
0
 def test_x_kw_placeholder(self):
     xf = xpartial(dummy, kwarg=X)
     assert xf(1) == ((), {'kwarg': 1})
Example #13
0
 def test_x_placeholder(self):
     xf = xpartial(dummy, X, 2)
     assert xf(1) == ((1, 2), {})
Example #14
0
 def test_should_behave_like_partial(self):
     xf = xpartial(dummy, 1, kwarg='kwarg')
     assert xf(2, foo='bar') == ((1, 2), {'kwarg': 'kwarg', 'foo': 'bar'})
Example #15
0
        self.test_args = []
        self.test_suite = True

    def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import pytest
        error_code = pytest.main(self.test_args)
        sys.exit(error_code)


setup(
    name='pipetools',
    version=pipetools.__versionstr__,
    description=('A library that enables function composition similar to '
        'using Unix pipes.'),
    long_description='README.rst' > xpartial(io.open, X, encoding="utf-8") | X.read(),
    author='Petr Pokorny',
    author_email='*****@*****.**',
    license='MIT',
    url='http://0101.github.com/pipetools/',
    packages=['pipetools'],
    include_package_data=True,
    install_requires=(
         'setuptools>=0.6b1',
    ),
    tests_require=(
        'pytest',
    ),
    cmdclass={'test': PyTest},

    classifiers=[
Example #16
0
        self.test_args = []
        self.test_suite = True

    def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import pytest
        error_code = pytest.main(self.test_args)
        sys.exit(error_code)


setup(name='pipetools',
      version=pipetools.__versionstr__,
      description=('A library that enables function composition similar to '
                   'using Unix pipes.'),
      long_description='README.rst' >
      xpartial(io.open, X, encoding="utf-8") | X.read(),
      author='Petr Pokorny',
      author_email='*****@*****.**',
      license='MIT',
      url='https://0101.github.io/pipetools/',
      packages=['pipetools'],
      include_package_data=True,
      install_requires=('setuptools>=0.6b1', ),
      tests_require=('pytest', ),
      cmdclass={'test': PyTest},
      classifiers=[
          'Development Status :: 5 - Production/Stable',
          'Intended Audience :: Developers',
          'License :: OSI Approved :: MIT License',
          'Operating System :: OS Independent',
          'Programming Language :: Python :: 2',