testing-cabal / testtools

Testtools - tasteful testing for python
https://testtools.readthedocs.io/en/latest/
Other
95 stars 88 forks source link

python-3.x build fails building 2.x file #254

Closed 0-wiz-0 closed 6 years ago

0-wiz-0 commented 7 years ago

A build of 2.2.0 with python-3.6 tries to build _compat2x.py and fails. This doesn't break the build, but I think it shouldn't even try.

byte-compiling /scratch/devel/py-testtools/work/.destdir/usr/pkg/lib/python3.6/site-packages/testtools/twistedsupport/_matchers.py to _matchers.cpython-36.pyc
writing byte-compilation script '/tmp/tmpj8rfuqmo.py'
/usr/pkg/bin/python3.6 /tmp/tmpj8rfuqmo.py
  File "/usr/pkg/lib/python3.6/site-packages/testtools/_compat2x.py", line 16
    raise exc_class, exc_obj, exc_tb
                   ^
SyntaxError: invalid syntax

removing /tmp/tmpj8rfuqmo.py

This also breaks the test target for setup.py (py.test is unaffected).

freeekanayaka commented 7 years ago

Hi,

I've added Python 3.6 to the list of Travis targets, and tests are green:

https://travis-ci.org/testing-cabal/testtools/builds/204269411

I'm not entirely sure what you mean by "build". Could you clarify what breaks exactly?

The code that imports _compat2x looks like this:

try:
    from testtools import _compat2x as _compat
except SyntaxError:
    from testtools import _compat3x as _compat

which is safe from an import point of view.

0-wiz-0 commented 7 years ago

Sure, here's the output of the breakage I see:

# python3.6 setup.py test
running test
running egg_info
writing testtools.egg-info/PKG-INFO
writing dependency_links to testtools.egg-info/dependency_links.txt
writing requirements to testtools.egg-info/requires.txt
writing top-level names to testtools.egg-info/top_level.txt
writing pbr to testtools.egg-info/pbr.json
[pbr] Processing SOURCES.txt
[pbr] In git context, generating filelist from git
warning: no files found matching 'AUTHORS'
warning: no files found matching 'ChangeLog'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'doc/_build'
writing manifest file 'testtools.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 16, in <module>
    pbr=True)
  File "/usr/pkg/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/pkg/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/pkg/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/pkg/lib/python3.6/site-packages/setuptools/command/test.py", line 211, in run
    self.run_tests()
  File "/usr/pkg/lib/python3.6/site-packages/setuptools/command/test.py", line 234, in run_tests
    **exit_kwarg
  File "/usr/pkg/lib/python3.6/unittest/main.py", line 93, in __init__
    self.parseArgs(argv)
  File "/usr/pkg/lib/python3.6/unittest/main.py", line 123, in parseArgs
    self._do_discovery([])
  File "/usr/pkg/lib/python3.6/unittest/main.py", line 228, in _do_discovery
    self.test = loader.discover(self.start, self.pattern, self.top)
  File "/usr/pkg/lib/python3.6/unittest/loader.py", line 341, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "/usr/pkg/lib/python3.6/unittest/loader.py", line 398, in _find_tests
    full_path, pattern, namespace)
  File "/usr/pkg/lib/python3.6/unittest/loader.py", line 475, in _find_test_path
    tests = self.loadTestsFromModule(package, pattern=pattern)
  File "/usr/pkg/lib/python3.6/site-packages/setuptools/command/test.py", line 43, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/usr/pkg/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "/disk/6/archive/foreign/testtools/testtools/_compat2x.py", line 16
    raise exc_class, exc_obj, exc_tb
                   ^
SyntaxError: invalid syntax
freeekanayaka commented 7 years ago

This might be not NetBSD-specific. I'll have a look tomorrow.

sebasmannem commented 6 years ago

I'm experiencing the same with centos7 / testtools 2.3.0. I'm trying to build an rpm.

rbtcollins commented 6 years ago

distutils is trying to byte compile every file copied across. To be universal our wheels and setup need to have the same content on different python versions - and as we do conditional imports theres no need to have changes. The warning - its a warning - is harmless.

rbtcollins commented 6 years ago

(its so harmless that pip doesn't even show you the output normally, so you have to actively seek this out to see it).