pydocstyle icon indicating copy to clipboard operation
pydocstyle copied to clipboard

tests break in Python 3 environment

Open danstender opened this issue 8 years ago • 9 comments

Hi, test_integration breaks in a Python 3 environment:

--- a/src/tests/test_integration.py
+++ b/src/tests/test_integration.py
@@ -100,7 +100,7 @@
 @pytest.yield_fixture(scope="module")
 def install_package(request):
     cwd = os.path.join(os.path.dirname(__file__), '..', '..')
-    install_cmd = "python setup.py develop"
+    install_cmd = "python3 setup.py develop"
     uninstall_cmd = install_cmd + ' --uninstall'
     subprocess.check_call(shlex.split(install_cmd), cwd=cwd)
     yield

BTW a new Debian package of pydocstyle is coming up.

danstender avatar Mar 02 '16 19:03 danstender

I suspect this is because the tests are run inside of tox for us. That said, I'm not sure this patch is correct for the project. I understand how Debian is building the packages is a bit naive when considering Python 2 versus Python 3, but doing this pytest fixture should work on Python 2 and Python 3. This patch would break the Python 2 tests.

sigmavirus24 avatar Mar 02 '16 20:03 sigmavirus24

@sigmavirus24 is correct in that tests are supposed to run under tox, which will define python to be the correct Python version. However, I think a simple solution that will be applicable to all cases would be to use sys.executable.

Nurdok avatar Mar 02 '16 20:03 Nurdok

Yes, o.k., I'll take a second look if that patch is really needed to run/build on Py3. Wasn't mend to adopt, either, but just as a pointer.

Thanks, DS

danstender avatar Mar 02 '16 20:03 danstender

Out of curiosity, why is it needed to maintain Debian packages for Python packages? I develop on Ubuntu (sometimes), but I will always opt for using pip when I can.

Nurdok avatar Mar 02 '16 20:03 Nurdok

It's not pointless ...

danstender avatar Mar 02 '16 20:03 danstender

I'm not suggesting it is, I'm genuinely asking - when and why would you use a Debian package of a Python library over installing it via pip?

Nurdok avatar Mar 02 '16 20:03 Nurdok

@Nurdok lots of people trust signed packages over packages delivered over TLS from untrusted sources. PyPI is uncurated while Debian's repositories are ... somewhat curated. The repositories often check for namespace collisions with respect to command-line names (console scripts), library/module names, etc.

While it never serves you or me any benefit when we're on those systems, it does help a lot of people. It also allows people a single source of truth when auditing a system's installed software. dpkg -l can list everything it knows about but everything installed via pip will be hidden from dpkg. It's not the greatest answer, but there are a lot of people who prefer that.

sigmavirus24 avatar Mar 02 '16 21:03 sigmavirus24

Another one has appeared.

test_run_as_named_module uses python -m pydocstyle and doesnt use sys.executable , which means it points to python2 on distos, and may not exist on a build machine which doesnt have python2 installed.

With this fixed, patch coming, the tests all pass on a machine without python2.

jayvdb avatar Sep 15 '19 07:09 jayvdb

@danstender, fwiw, I havent fixed the fixture install_package in my PR, as I assume you are only interested in that for packaging, and the best solution for that is to disable that fixture in your build script.

sed -i /^pytestmark/d src/tests/test_integration.py

c.f. openSUSE package update request https://build.opensuse.org/request/show/731067

jayvdb avatar Sep 15 '19 09:09 jayvdb