nexus3-cli icon indicating copy to clipboard operation
nexus3-cli copied to clipboard

Some issues running integration tests with pytest

Open f18m opened this issue 5 years ago • 4 comments

Hi, I'm not an expert of pytest and I'm trying to run integration tests. I'm running them on Ubuntu 18.04. Since nexus3-cli is using Python3 and the distro defaults to Python2 I did the following

$ virtualenv -p /usr/bin/python3 py3env
$ source py3env/bin/activate


$ pip --version  # I have pip 19.3.1 from /home/francesco/work/nexus3-cli/py3env/lib/python3.6/site-packages/pip (python 3.6)

$ pip install  -e .
$ pip install pytest faker

$ docker run -d --rm -p 127.0.0.1:8081:8081 --name nexus sonatype/nexus3
$ ./tests/wait-for-nexus.sh  # the Nexus instance takes a while to be ready
$ ./tests/nexus-login $(docker exec nexus cat /nexus-data/admin.password)

$ pytest -m integration

stty: 'standard input': Inappropriate ioctl for device
ImportError while loading conftest '/home/francesco/work/nexus3-cli/tests/conftest.py'.
tests/conftest.py:60: in <module>
    @pytest.helpers.register
E   AttributeError: module 'pytest' has no attribute 'helpers'

what am I missing? I have pytest == 5.3.2 and Faker==3.0.0...

thanks

f18m avatar Dec 24 '19 12:12 f18m

I forgot to add that I tried the following after some Googling:

$ pip install pytest-helpers-namespace
...
Successfully installed pytest-helpers-namespace-2019.1.8

$ pytest -m integration
stty: 'standard input': Inappropriate ioctl for device
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --cov --cov-report term --cov-append
  inifile: /home/francesco/work/nexus3-cli/setup.cfg
  rootdir: /home/francesco/work/nexus3-cli

f18m avatar Dec 24 '19 12:12 f18m

ok sorry I realized that actually the "[test]" part in the README.md is not optional... the syntax sidetracked me a little bit.

I now did:

$ pip install -e .[test]
$ pytest -m integration

Traceback (most recent call last):
  File "/home/francesco/work/nexus3-cli/py3env2/lib/python3.6/site-packages/coverage/sqldata.py", line 1032, in execute
    return self.con.execute(sql, parameters)
sqlite3.DatabaseError: file is not a database

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/francesco/work/nexus3-cli/py3env2/bin/pytest", line 8, in <module>
    sys.exit(main())
...
  File "/home/francesco/work/nexus3-cli/py3env2/lib/python3.6/site-packages/coverage/sqldata.py", line 1047, in execute
    raise CoverageException("Couldn't use data file {!r}: {}".format(self.filename, msg))
coverage.misc.CoverageException: Couldn't use data file '/home/francesco/work/nexus3-cli/.coverage': Looks like a coverage 4.x data file. Are you mixing versions of coverage?

$ pip list | grep coverage
coverage                 5.0.1      


Should I install the coverage 4.x ?

f18m avatar Dec 24 '19 12:12 f18m

Read the .travisci steps but I think you’re missing the test dependencies; i.e.:

pip install -e .[test]

Sent on the run; please excuse my brevity.

On 24 Dec 2019, at 12:32, Francesco Montorsi [email protected] wrote:

 Hi, I'm not an expert of pytest and I'm trying to run integration tests. I'm running them on Ubuntu 18.04. Since nexus3-cli is using Python3 and the distro defaults to Python2 I did the following

$ virtualenv -p /usr/bin/python3 py3env $ source py3env/bin/activate

$ pip --version # I have pip 19.3.1 from /home/francesco/work/nexus3-cli/py3env/lib/python3.6/site-packages/pip (python 3.6)

$ pip install -e . $ pip install pytest faker

$ docker run -d --rm -p 127.0.0.1:8081:8081 --name nexus sonatype/nexus3 $ ./tests/wait-for-nexus.sh # the Nexus instance takes a while to be ready $ ./tests/nexus-login $(docker exec nexus cat /nexus-data/admin.password)

$ pytest -m integration

stty: 'standard input': Inappropriate ioctl for device ImportError while loading conftest '/home/francesco/work/nexus3-cli/tests/conftest.py'. tests/conftest.py:60: in @pytest.helpers.register E AttributeError: module 'pytest' has no attribute 'helpers'

what am I missing? I have pytest == 5.3.2 and Faker==3.0.0...

thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

thiagofigueiro avatar Dec 24 '19 14:12 thiagofigueiro

Read the .travisci steps but I think you’re missing the test dependencies; i.e.: pip install -e .[test]

right thanks! however the problem is that coverage 5.x seems incompatible with coverage 4.x... maybe the test_requires list should be adjusted to ensure 4.x is used...

f18m avatar Dec 24 '19 18:12 f18m