neithere / argh

An argparse wrapper that doesn't make you say "argh" each time you deal with it.
http://argh.rtfd.org
GNU Lesser General Public License v3.0
369 stars 56 forks source link

integration test broken on python 2.7.10 (test_unknown_args) #96

Closed anthraxx closed 8 years ago

anthraxx commented 8 years ago

broken with python 2.7.10 (works fine with python3):

============================= test session starts ==============================
platform linux2 -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /build/python-argh/src/argh-0.26.1, inifile: 
collected 80 items

test/test_assembling.py .......ss...ss..
test/test_compat.py .
test/test_decorators.py ......
test/test_dispatching.py ..
test/test_integration.py x.......xxx..............................s...F
test/test_interaction.py ...
test/test_regressions.py ......

=================================== FAILURES ===================================
______________________________ test_unknown_args _______________________________

    def test_unknown_args():

        def cmd(foo=1):
            return foo

        p = DebugArghParser()
        p.set_default_command(cmd)

        assert run(p, '--foo 1') == R(out='1\n', err='')
        assert run(p, '--bar 1', exit=True) == 'unrecognized arguments: --bar 1'
>       assert run(p, '--bar 1', exit=False,
                   kwargs={'skip_unknown_args': True}) == \
               R(out='usage: py.test [-h] [-f FOO]\n\n', err='')
E       assert CmdResult(out...\n\n', err='') == CmdResult(out=...\n\n', err='')
E         At index 0 diff: 'usage: py.test2 [-h] [-f FOO]\n\n' != 'usage: py.test [-h] [-f FOO]\n\n'
E         Use -v to get the full diff

test/test_integration.py:773: AssertionError
========== 1 failed, 70 passed, 5 skipped, 4 xfailed in 0.55 seconds ===========
kpcyrd commented 8 years ago

I couldn't reproduce this with tox -e py27. I think this happens if you have installed and invoke py.test as py.test2, since it alters argv[0].

Edit: this is related to #83

neithere commented 8 years ago

@kpcyrd It's related indeed, thank you! Will merge the PR after conflicts are solved in that branch.

neithere commented 8 years ago

UPD: it was actually fixed in 0.26.2-dev which is not yet released.

anthraxx commented 8 years ago

@neithere can you point at the commit hash so i can backport it until a new release is out? (new release is of cause also a solution :yum: ) I want to move this into the repos :smile:

is the commit actually the b8ee9c3 listed in #83 ?

neithere commented 8 years ago

Yep, this one. The problem was only in tests, not in lib.