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

tests/test.py fails with invalid syntax #23

Open
nieder opened this issue Oct 17, 2022 · 1 comment
Open

tests/test.py fails with invalid syntax #23

nieder opened this issue Oct 17, 2022 · 1 comment

Comments

@nieder
Copy link

nieder commented Oct 17, 2022

Testing 1.3.0, running tests fails like this:

$ PYTHONPATH=/sw/build.build/pygogo-py38-1.3.0-1/pygogo-1.3.0/build/lib /sw/bin/python3.8 tests/test.py
Script result: /sw/build.build/pygogo-py38-1.3.0-1/pygogo-1.3.0/bin/gogo --help
  return code: 1
-- stderr: --------------------
Traceback (most recent call last):
  File "/sw/build.build/pygogo-py38-1.3.0-1/pygogo-1.3.0/bin/gogo", line 13, in <module>
    from pygogo import main
  File "/sw/build.build/pygogo-py38-1.3.0-1/pygogo-1.3.0/build/lib/pygogo/__init__.py", line 49, in <module>
    from . import formatters, handlers, utils
  File "/sw/build.build/pygogo-py38-1.3.0-1/pygogo-1.3.0/build/lib/pygogo/formatters.py", line 405
    logging.DEBUG: f"{debug_color} {self._fmt} {RESET}",
                                                      ^
SyntaxError: invalid syntax

Traceback (most recent call last):
  File "tests/test.py", line 98, in <module>
    main(script, tests)
  File "tests/test.py", line 44, in main
    result = env.run(command, cwd=p.abspath(p.dirname(p.dirname(__file__))))
  File "/sw/lib/python3.8/site-packages/scripttest.py", line 273, in run
    result.assert_no_error(quiet)
  File "/sw/lib/python3.8/site-packages/scripttest.py", line 426, in assert_no_error
    raise AssertionError(
AssertionError: Script returned code: 1

/sw/bin/nosetests3.8 -xv finished fine with no errors in 57 tests. This failure happens with py3.8, 3.9, and 3.10. This is macOS 10.14.5, but I don't think this would matter given the error type.

@nieder
Copy link
Author

nieder commented Jun 6, 2023

The issue here is that bin/gogo uses #!/usr/bin/env python (which is often python-2.7) even when told to use a specific python. pygogo/main.py also does not change the python interpreter to use. And so the test fails because gogo doesn't inherit the python3.8 (in my example) call that launched the tests.

Changing the #! line to an explicit python interpreter makes all tests pass.

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

1 participant