browncoat-ninjas / nimoy

A testing and specification framework for Python 3
https://browncoat-ninjas.github.io/nimoy
Apache License 2.0
105 stars 12 forks source link

Is it pissible run code in IDE (PyCharm)? #12

Open Hubbitus opened 5 years ago

Hubbitus commented 5 years ago

First very thanks for creating such framework. I'm big fan of Spock and DDT in Java/Groovy world. I try nimoy and it looks very promissing, but I have problem run its code in PyCharm

Version: 0.0.1b7

Said I have code:

class MinimalSpec(Specification):
    def test_feature_method(self):
        with given:
            a = 'The quick brown fox'
        with expect:
            a == 'The quick Brown Fox'

If I run in command-line in venv I got expected output:

...
AssertionError: 
Expected: 'The quick Brown Fox'
     but: was 'The quick brown fox'
Hint:
- The quick brown fox
?           ^     ^

+ The quick Brown Fox
?           ^     ^

But when I run it in PyCharm I got error:

Ran 1 test in 0.002s

FAILED (errors=1)

Error
Traceback (most recent call last):
  File "/usr/lib64/python3.7/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/lib64/python3.7/unittest/case.py", line 615, in run
    testMethod()
  File "/home/pasha/@Projects/@Senso/python-flask/venv/lib64/python3.7/site-packages/nimoy/specification.py", line 14, in helper
    return test_method(*args, **kwargs)
  File "/home/pasha/@Projects/@Senso/python-flask/tests/DB_spec.py", line 8, in test_feature_method
    with given:
NameError: name 'given' is not defined

It is reasonably expected. But may be it is possible hook such execution without writing heavy Idea plugin and so on? F.e. what if create and import variables like given, expect, when, then, etc?

noamt commented 5 years ago

Thanks for the feedback. You can't run a Nimoy spec like an ordinary unittest in PyCharm as I've hadn't had the time to write a pycharm plugin yet

Hubbitus commented 4 years ago

Initially I ask workarounds without write plugins. Is it really possible?

Hubbitus commented 4 years ago

As temporary workaround it may be run similarly to https://aditamasblog.wordpress.com/2018/07/26/setting-up-pycharm-community-edition-to-work-with-python-behave/, so providing venv/bin/nimoy in script path parameter in Run/Debug configurations dialog

noamt commented 4 years ago

Yes, that's a fine workaround