8000 py.test ... --ruledir leads to "unrecognized arguments: --ruledir" · Issue #11 · coreruleset/ftw · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

py.test ... --ruledir leads to "unrecognized arguments: --ruledir" #11

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 t 8000 o our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dune73 opened this issue Sep 29, 2017 · 18 comments · Fixed by #12
Closed

py.test ... --ruledir leads to "unrecognized arguments: --ruledir" #11

dune73 opened this issue Sep 29, 2017 · 18 comments · Fixed by #12

Comments

@dune73
Copy link
Member
dune73 commented Sep 29, 2017

Time to get my feet wet with this, but the README.md does not work for me.

ftw> py.test test/test_default.py --ruledir test/yaml
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --ruledir test/yaml

What am I doing wrong?

@dune73 dune73 assigned dune73 and unassigned dune73 Sep 29, 2017
@franbuehler
Copy link

I tested it and I get the same error as @dune73.

@zmallen
Copy link
Collaborator
zmallen commented Oct 25, 2017

@franbuehler @dune73 just saw this, didnt have notifications on. Will look into it -- could be a versioning mismatch in the README

@dune73
Copy link
Member Author
dune73 commented Oct 25, 2017

I see. Yes, please help us to fix this. @csanders-git has written two blog posts for Core Rule Set and they both don't work because of this bug.

Also: Can we reach you via email? Mine is christian.folini@netnea.com

@zmallen
Copy link
Collaborator
zmallen commented Oct 27, 2017

hi @dune73 and @franbuehler
I couldnt replicate your bug but I found one potential issue that may help with pathing in #12. Can you please rebase?

It automatically closed this issue on that merge, so I reopened it.

Are you spawning this in a virtualenvironment?

Try these install steps:

virtualenv env; source . env/bin/activate; pip install -r requirements.txt

then

py.test test/test_default.py --ruledir=test/yaml

@zmallen zmallen reopened this Oct 27, 2017
@dune73
Copy link
Member Author
dune73 commented Oct 27, 2017

Thank you. I'll try it again and report back.

@dune73
Copy link
Member Author
dune73 commented Oct 28, 2017

No luck. Here is what I did:

dune73@leander tmp>git clone https://github.com/CRS-support/ftw.git
...
dune73@leander tmp>cd /tmp/ftw
dune73@leander ftw>virtualenv env
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/ftw/env/bin/python2
Not overwriting existing python script /tmp/ftw/env/bin/python (you must use /tmp/ftw/env/bin/python2)
Installing setuptools, pkg_resources, pip, wheel...done.
dune73@leander ftw>source ./env/bin/activate
(env) dune73@leander ftw>py.test test/test_default.py --ruledir=test/yaml
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --ruledir=test/yaml
  inifile: None
  rootdir: /tmp/ftw
(env) dune73@leander ftw>pip install -r requirements.txt
Collecting astroid==1.4.5 (from -r requirements.txt (line 1))
  Using cached astroid-1.4.5-py2.py3-none-any.whl
Collecting colorama==0.3.7 (from -r requirements.txt (line 2))
  Using cached colorama-0.3.7-py2.py3-none-any.whl
Collecting IPy==0.83 (from -r requirements.txt (line 3))
  Using cached IPy-0.83.tar.gz
Collecting lazy-object-proxy==1.2.2 (from -r requirements.txt (line 4))
  Downloading lazy_object_proxy-1.2.2-cp27-cp27mu-manylinux1_x86_64.whl (56kB)
    100% |████████████████████████████████| 61kB 582kB/s 
Collecting py==1.4.31 (from -r requirements.txt (line 5))
  Using cached py-1.4.31-py2.py3-none-any.whl
Collecting pylint==1.5.5 (from -r requirements.txt (line 6))
  Using cached pylint-1.5.5-py2.py3-none-any.whl
Collecting pytest==2.9.1 (from -r requirements.txt (line 7))
  Using cached pytest-2.9.1-py2.py3-none-any.whl
Collecting PyYAML==3.11 (from -r requirements.txt (line 8))
  Downloading PyYAML-3.11.zip (371kB)
    100% |████████████████████████████████| 378kB 496kB/s 
Collecting requests==2.9.1 (from -r requirements.txt (line 9))
  Using cached requests-2.9.1-py2.py3-none-any.whl
Collecting six==1.10.0 (from -r requirements.txt (line 10))
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting wrapt==1.10.8 (from -r requirements.txt (line 11))
  Using cached wrapt-1.10.8.tar.gz
Collecting python-dateutil==2.6.0 (from -r requirements.txt (line 12))
  Using cached python_dateutil-2.6.0-py2.py3-none-any.whl
Building wheels for collected packages: IPy, PyYAML, wrapt
  Running setup.py bdist_wheel for IPy ... done
  Stored in directory: /home/dune73/.cache/pip/wheels/2b/1e/e1/9a9d6e33c211128ec866e9e15ae7c34bc2e1d3d2d7e703ecaf
  Running setup.py bdist_wheel for PyYAML ... done
  Stored in directory: /home/dune73/.cache/pip/wheels/4a/bf/14/d79994d19a59d4f73efdafb8682961f582d45ed6b459420346
  Running setup.py bdist_wheel for wrapt ... done
  Stored in directory: /home/dune73/.cache/pip/wheels/19/8a/01/20cf74c3f38d49ef8e9b9aa7ffd38cefff79bad9f6f2c651f0
Successfully built IPy PyYAML wrapt
Installing collected packages: wrapt, lazy-object-proxy, six, astroid, colorama, IPy, py, pylint, pytest, PyYAML, requests, python-dateutil
Successfully installed IPy-0.83 PyYAML-3.11 astroid-1.4.5 colorama-0.3.7 lazy-object-proxy-1.2.2 py-1.4.31 pylint-1.5.5 pytest-2.9.1 python-dateutil-2.6.0 requests-2.9.1 six-1.10.0 wrapt-1.10.8
(env) 
dune73@leander ftw>py.test test/test_default.py --ruledir=test/yaml
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --ruledir=test/yaml
  inifile: None
  rootdir: /tmp/ftw

There is this remark Not overwriting existing python script ..., otherwise, I do not see anything suspicious.

Also: You removed the example call from your README.md.

@zmallen
Copy link
Collaborator
zmallen commented Oct 28, 2017

Do you have FTW installed globally?

deactivate && pip freeze | grep ftw

Also what is your python version?

Edit:

I replicated your bug. Sorry about this -- the tl;dr is that I removed conftest.py which is a plugin manager for pytest, it allows ability for us to add arguments to pytest like --ruledir.

I removed it because I shipped it into ftw/pytest_plugin.py. The idea is that when someone installs ftw from setuptools (pip, for example) py.test will then load our custom plugin.

The fix here is then to add conftest.py into the test/ directory if you want to git clone ftw and work the library itself.

Otherwise, if youd like to use FTW in a completely separate project, nothing should change, just pip install ftw and start writing.

I'm submitting a P/R to fix this and will update the README.

@zmallen
Copy link
Collaborator
zmallen commented Oct 28, 2017

Can you try #14 @dune73 and @franbuehler and let me know if that works? Just replicated your bug locally and got it fixed with that P/R

@dune73
Copy link
Member Author
dune73 commented Oct 28, 2017

Much better. Thank you. But still not quite there:

py.test -s -v test/test_default.py --ruledir=test/yaml
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 283, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/tmp/ftw/test/test_default.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 283, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/tmp/ftw/test')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 314, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/tmp/ftw/test/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 320, in _importconftest
    mod = conftestpath.pyimport()
  File "/usr/local/lib/python3.5/dist-packages/py/_path/local.py", line 650, in pyimport
    __import__(modname)
  File "/tmp/ftw/test/conftest.py", line 2, in <module>
    from ftw.ftw import ruleset, util
ImportError: No module named 'ftw'
ERROR: could not load /tmp/ftw/test/conftest.py

My python version:

$> python -V
Python 2.7.12+

@zmallen
Copy link
Collaborator
zmallen commented Oct 28, 2017

Whats your pytest version?
py.test --version

@dune73
Copy link
Member Author
dune73 commented Oct 28, 2017 < 8000 /div>
$> py.test --version
This is pytest version 2.9.1, imported from /usr/local/lib/python3.5/dist-packages/pytest.py

Oops. Is that python3.5 the problem?

@zmallen
Copy link
Collaborator
zmallen commented Oct 28, 2017

It could be -- virtualenv shouldve dropped you into python 2.7. Can you deactivate && pip uninstall pytest?

@zmallen
Copy link
Collaborator
zmallen commented Oct 28, 2017

Then youd drop back into the virtualenv, make sure the version is in the local path and test again.

It works with fresh virtualenv with me for the fix, I have to update the tests to import correctly now, though.

@dune73
Copy link
Member Author
dune73 commented Oct 29, 2017

What does deactivate mean?

@zmallen
Copy link
Collaborator
zmallen commented Nov 6, 2017

@dune73 deactivate your virtual environment

@dune73
Copy link
Member Author
dune73 commented Nov 6, 2017

Thanks. Got it at last.

OK, I applied #14 to FTW and ran through the README and it worked.

(env) dune73@anastasia ftw>py.test -s -v test/test_default.py --ruledir=test/yaml
===================================================================== test session starts =====================================================================
platform linux2 -- Python 2.7.12, pytest-2.9.1, py-1.4.31, pluggy-0.3.1 -- /tmp/ftw/env/bin/python2
cachedir: .cache
rootdir: /tmp/ftw, inifile: 
collected 2 items 

test/test_default.py::test_default[ruleset0-EXAMPLE.yaml -- 1234] PASSED
test/test_default.py::test_default[ruleset1-EXAMPLE.yaml -- 1235] PASSED

================================================================== 2 passed in 0.82 seconds ===================================================================

That's great. The sooner you merge, the better. ;)

@zmallen
Copy link
Collaborator
zmallen commented Nov 6, 2017

@dune73 yay! Sorry about the confusion. Ill need to get this approved then Ill tag and rerelease to pypi.

If you find me on IRC i can give you a better explanation on what happened

@dune73
Copy link
Member Author
dune73 commented Nov 7, 2017

So the PR #14 which has been merged in the meantime solved this for me. Closing this.

Thank you for all the debugging @zmallen.

@dune73 dune73 closed this as completed Nov 7, 2017
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

Successfully merging a pull request may close this issue.

3 participants
0