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

Question about running tests #208

Closed
esc opened this Issue Sep 22, 2015 · 10 comments

Comments

Projects
None yet
2 participants
@esc
Member

esc commented Sep 22, 2015

Is it possible to run individual tests?

@mriehl mriehl added the question label Sep 22, 2015

@mriehl

This comment has been minimized.

Show comment
Hide comment
@mriehl

mriehl Sep 22, 2015

Member

There's a hack if you want to test just a module:

 pyb -P unittest_module_glob=reactor_tests.py

whith s/reactor_tests/your_test_module/ of course. There's no easy way to run just a test in a module right now though.

Member

mriehl commented Sep 22, 2015

There's a hack if you want to test just a module:

 pyb -P unittest_module_glob=reactor_tests.py

whith s/reactor_tests/your_test_module/ of course. There's no easy way to run just a test in a module right now though.

@mriehl

This comment has been minimized.

Show comment
Hide comment
@mriehl

mriehl Sep 22, 2015

Member

Actually there is: you can override unittest_test_method_prefix with the -P switch. Same as the module example I added but with method name.

Member

mriehl commented Sep 22, 2015

Actually there is: you can override unittest_test_method_prefix with the -P switch. Same as the module example I added but with method name.

@esc

This comment has been minimized.

Show comment
Hide comment
@esc

esc Sep 22, 2015

Member

Interesting. I usually ended up with my own hack using nosetests:

PYTHONPATH=src/main/python nosetests test_module:TestClass.test_method

But this depends on correctly set PYTHONPATH. And so one thing I would really like to see is the ability to modify the environment using pybuilder to inject the PYTHONPATH, for example the way the ssh-agent does it.

eval pyb export_env
Member

esc commented Sep 22, 2015

Interesting. I usually ended up with my own hack using nosetests:

PYTHONPATH=src/main/python nosetests test_module:TestClass.test_method

But this depends on correctly set PYTHONPATH. And so one thing I would really like to see is the ability to modify the environment using pybuilder to inject the PYTHONPATH, for example the way the ssh-agent does it.

eval pyb export_env
@mriehl

This comment has been minimized.

Show comment
Hide comment
@mriehl

mriehl Sep 22, 2015

Member

Hmm.. that would definitely be really easy to add. Question is, what do you gain from it? Right now you export PYTHONPATH=src/main/python. With a task you'd still have to type eval pyb export_env which is not noticeably shorter.

I think it would be better to have an actual task that takes parameters, like
pyb run_nose "test_module:TestClass.test_method" (but we can not even parse this right now).
For this exact use case you could add a zsh function that sets both properties (module glob and method prefix).

Member

mriehl commented Sep 22, 2015

Hmm.. that would definitely be really easy to add. Question is, what do you gain from it? Right now you export PYTHONPATH=src/main/python. With a task you'd still have to type eval pyb export_env which is not noticeably shorter.

I think it would be better to have an actual task that takes parameters, like
pyb run_nose "test_module:TestClass.test_method" (but we can not even parse this right now).
For this exact use case you could add a zsh function that sets both properties (module glob and method prefix).

@esc

This comment has been minimized.

Show comment
Hide comment
@esc

esc Sep 22, 2015

Member

Yeah, I'll do that. Can I get pyb to print the module and scripts path?

Member

esc commented Sep 22, 2015

Yeah, I'll do that. Can I get pyb to print the module and scripts path?

@mriehl

This comment has been minimized.

Show comment
Hide comment
@mriehl

mriehl Sep 22, 2015

Member

You need to add a task for that :-/
We could consider adding these to the core python plugin since it's pretty neat for shell usage (like setting the pythonpath before starting vim, etc).

@task
def print_module_path(project):
    print(project.expand_path("$dir_source_main_python"))

@task
def print_scripts_path(project):
    print(project.expand_path("$dir_source_main_scripts"))

and then call the task with -Q (very quiet).

Member

mriehl commented Sep 22, 2015

You need to add a task for that :-/
We could consider adding these to the core python plugin since it's pretty neat for shell usage (like setting the pythonpath before starting vim, etc).

@task
def print_module_path(project):
    print(project.expand_path("$dir_source_main_python"))

@task
def print_scripts_path(project):
    print(project.expand_path("$dir_source_main_scripts"))

and then call the task with -Q (very quiet).

@esc

This comment has been minimized.

Show comment
Hide comment
@esc

esc Sep 22, 2015

Member

Yeah, that would suffice for my use-case. Everything, else I can do by shell function. It's probably only an edge-case, since I don't know any projects that override these defaults, but just in case it would be neato and would help interoperability between pybuilder and other tools.

Member

esc commented Sep 22, 2015

Yeah, that would suffice for my use-case. Everything, else I can do by shell function. It's probably only an edge-case, since I don't know any projects that override these defaults, but just in case it would be neato and would help interoperability between pybuilder and other tools.

@esc

This comment has been minimized.

Show comment
Hide comment
@esc

esc Oct 7, 2015

Member

The original question has been answered. I'd like to close this issue and make a new one for the suggestions about the additional tasks, OK?

Member

esc commented Oct 7, 2015

The original question has been answered. I'd like to close this issue and make a new one for the suggestions about the additional tasks, OK?

@mriehl

This comment has been minimized.

Show comment
Hide comment
@mriehl

mriehl Oct 7, 2015

Member

Works for me!

Member

mriehl commented Oct 7, 2015

Works for me!

@mriehl mriehl closed this Oct 22, 2015

@esc

This comment has been minimized.

Show comment
Hide comment
@esc

esc Nov 6, 2015

Member

See: #239

Member

esc commented Nov 6, 2015

See: #239

mriehl added a commit that referenced this issue Nov 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment