Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to run initial behave and test error #945

Closed
3 tasks done
igncampa opened this issue Sep 25, 2018 · 5 comments
Closed
3 tasks done

fail to run initial behave and test error #945

igncampa opened this issue Sep 25, 2018 · 5 comments

Comments

@igncampa
Copy link
Contributor

igncampa commented Sep 25, 2018

Description

I pulled the repo to my machine and followed the contributing guide. Running behave and py.test both gave me an error:

behave command gives the following error:

package root: /home/igncampa/Repos/pgcli
fixture dir: /home/igncampa/Repos/pgcli/tests/features/fixture_data
HOOK-ERROR in before_all: OperationalError: fe_sendauth: no password supplied
HOOK-ERROR in after_all: AttributeError: 'Context' object has no attribute 'cn'

ABORTED: By user.
0 features passed, 0 failed, 0 skipped, 8 untested
0 scenarios passed, 0 failed, 0 skipped, 16 untested
0 steps passed, 0 failed, 0 skipped, 0 undefined, 85 untested
Took 0m0.000s

also running py.test one of the tests fails:
test_naive_completion.py:65: AssertionError

in case it matters, on my pg_hba.conf I have:
local all postgres trust

Your environment

  • Please provide your OS and version information.
    Description: Ubuntu 18.04.1 LTS

  • Please provide your CLI version.
    psql (PostgreSQL) 10.5 (Ubuntu 10.5-1.pgdg18.04+1)

  • What is the output of pip freeze command.
    autopep8==1.3.3
    behave==1.2.6
    certifi==2018.8.24
    chardet==3.0.4
    cli-helpers==1.0.2
    click==6.7
    codecov==2.0.15
    colorama==0.3.9
    configobj==5.0.6
    coverage==4.3.4
    docformatter==1.0
    docutils==0.14
    humanize==0.5.1
    idna==2.7
    mock==2.0.0
    parse==1.8.4
    parse-type==0.4.2
    pbr==4.2.0
    pep8radius==0.9.2
    pexpect==3.3
    -e [email protected]:igncampa/pgcli.git@d3bdb89#egg=pgcli
    pgspecial==1.11.2
    pkg-resources==0.0.0
    pkginfo==1.4.2
    pluggy==0.7.1
    prompt-toolkit==1.0.15
    psycopg2==2.7.5
    psycopg2-binary==2.7.5
    py==1.6.0
    pycodestyle==2.4.0
    Pygments==2.2.0
    pytest==3.0.7
    requests==2.19.1
    requests-toolbelt==0.8.0
    setproctitle==1.1.10
    six==1.11.0
    sqlparse==0.2.4
    tabulate==0.8.2
    terminaltables==3.1.0
    toml==0.9.6
    tox==3.4.0
    tqdm==4.26.0
    twine==1.11.0
    untokenize==0.1.1
    urllib3==1.23
    virtualenv==16.0.0
    wcwidth==0.1.7
    yapf==0.24.0

@j-bennet
Copy link
Contributor

I recently encountered this error when local connections had trust auth, but host didn't. Changing host to trust works:

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

What kind of error do you get in test_naive_completion.py? Try py.test with verbose flag:

py.test -svv tests/test_naive_completion.py

@igncampa
Copy link
Contributor Author

I started a fresh terminal after setting the lines to trust on my pg_hba.conf but the problem persists. No change in the output.

The output of running test_naive_completion.py is the following:

============================= test session starts ==============================
platform linux -- Python 3.6.5, pytest-3.0.7, py-1.6.0, pluggy-0.4.0 -- /home/igncampa/Repos/venvs/pgcli/bin/python3.6
cachedir: .cache
rootdir: /home/igncampa/Repos/pgcli/tests, inifile: pytest.ini
collecting ... collected 6 items

test_naive_completion.py::test_empty_string_completion PASSED
test_naive_completion.py::test_select_keyword_completion PASSED
test_naive_completion.py::test_function_name_completion PASSED
test_naive_completion.py::test_column_name_completion PASSED
test_naive_completion.py::test_paths_completion FAILED
test_naive_completion.py::test_alter_well_known_keywords_completion PASSED

=================================== FAILURES ===================================
____________________________ test_paths_completion _____________________________

completer = <pgcli.pgcompleter.PGCompleter object at 0x7f7aab17a2b0>
complete_event = <Mock id='140164833192144'>

    def test_paths_completion(completer, complete_event):
        text = '\i '
        position = len(text)
        result = set(completer.get_completions(
            Document(text=text, cursor_position=position),
            complete_event,
            smart_completion=True))
>       assert result > set([Completion(text="setup.py", start_position=0)])
E       AssertionError: assert {Completion(text='metadata.py', start_position=0), Completion(text='conftest.py', start_position=0), Completion(text='...=0), Completion(text='test_prioritization.py', start_position=0), Completion(text='pytest.ini', start_position=0), ...} > {Completion(text='setup.py', start_position=0)}
E        +  where {Completion(text='setup.py', start_position=0)} = set([Completion(text='setup.py', start_position=0)])

complete_event = <Mock id='140164833192144'>
completer  = <pgcli.pgcompleter.PGCompleter object at 0x7f7aab17a2b0>
position   = 3
result     = {Completion(text='metadata.py', start_position=0), Completion(text='conftest.py', start_position=0), Completion(text='...=0), Completion(text='test_prioritization.py', start_position=0), Completion(text='pytest.ini', start_position=0), ...}
text       = '\\i '

test_naive_completion.py:65: AssertionError
====================== 1 failed, 5 passed in 0.12 seconds ======================

Thanks for the help.

@j-bennet
Copy link
Contributor

After changing pg_hba.conf, postgresql service needs a restart.

@j-bennet
Copy link
Contributor

@igncampa I got it, you're running tests from the wrong directory. To run tests:

cd /home/igncampa/Repos/pgcli
py.test -sv

to run behave tests:

cd /home/igncampa/Repos/pgcli/tests
behave

That test_paths_completion tests actual paths, not mocked. It is not very well designed, sorry.

@igncampa
Copy link
Contributor Author

Thank you, @j-bennet. You were right on both cases!

Looking forward to contributing some code!

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

No branches or pull requests

2 participants