asfaltboy / SublimeTestPlier

run python tests quickly from within a project
https://packagecontrol.io/packages/Test%20Plier
MIT License
10 stars 4 forks source link

Features from newer python versions cause syntax errors #21

Open asfaltboy opened 6 years ago

asfaltboy commented 6 years ago

For example using f-strings in tests (a python 3.6 feature), causes a SyntaxError when passing the test module so urce to ast.parse() using the builtin python3.3/ast.py. Full traceback below:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 795, in run_
    return self.run(**args)
  File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/SublimeTestPlier/python_test_plier.py", line 102, in run
    self.get_pattern(view)
  File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/SublimeTestPlier/python_test_plier.py", line 73, in get_pattern
    pattern = view and utils.get_test(view)
  File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/SublimeTestPlier/utils/__init__.py", line 83, in get_test
    class_name, method_name = parser.parse(line)
  File "/Users/pavel.savchenko/Library/Application Support/Sublime Text 3/Packages/SublimeTestPlier/test_parser.py", line 89, in parse
    tree = ast.parse(self.source)
  File "./python3.3/ast.py", line 35, in parse
  File "<unknown>", line 59
    print(f'some {kind} of test')
                               ^
SyntaxError: invalid syntax
dc-avasilev commented 5 years ago

same here, it's because f-string parser work on python3.3 -> need to be upgrade to 3.6 minimal

asfaltboy commented 5 years ago

Ooops, my bad! I forgot that I added support for pluggable python version a while back, and didn't update the docs.

Check out the PR here and let me know if it's sufficiently clarifying.

tl;dr sublime ships with 3.3. specify a path to python with desired version in your build system via:

"python_executable": "/usr/local/opt/python/bin/python3.7",
dc-avasilev commented 5 years ago

Ooops, my bad! I forgot that I added support for pluggable python version a while back, and didn't update the docs.

Check out the PR here and let me know if it's sufficiently clarifying.

tl;dr sublime ships with 3.3. specify a path to python with desired version in your build system via:

"python_executable": "/usr/local/opt/python/bin/python3.7",

it's not help

{
    "build_systems":
    [
        {
            "python_executable": "/Users/user/path/automation-services/.venv/bin/python3",
            "cmd": [
                "/Users/user/path/automation-services/.venv/bin/pytest",
                "{filename}::{test_func}",
                "-k {selection}"
            ],
            "name": "Pytest Runner",
            "target": "run_python_tests",
            "working_dir": "/Users/user/path/automation-services",
            "external": true  // with this and without
        }
    ]
}

i still have error f-string

asfaltboy commented 5 years ago

What version is /Users/user/path/automation-services/.venv/bin/python3 run python3 -V ?

If running this "Pytest Runner" build fails it should throw an exception in the console, can you show me the full traceback?

asfaltboy commented 5 years ago

@dc-avasilev have you had any chance to look into the logs? You could also try to enable SublimeTestPlier's verbose logging by adding "debug": true to your SublimeTestPlier.sublime-settings file. This will output your kwargs, as well as many of the calls in the test resolution flow.

For more information on editing user settings, see here: https://www.sublimetext.com/docs/3/settings.html