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

Question about running tests #208

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

Question about running tests #208

esc opened this issue Sep 22, 2015 · 10 comments
Labels

Comments

@esc
Copy link
Contributor

esc commented Sep 22, 2015

Is it possible to run individual tests?

@mriehl
Copy link
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
Copy link
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
Copy link
Contributor Author

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
Copy link
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
Copy link
Contributor Author

esc commented Sep 22, 2015

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

@mriehl
Copy link
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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Member

mriehl commented Oct 7, 2015

Works for me!

@mriehl mriehl closed this as completed Oct 22, 2015
@esc
Copy link
Contributor Author

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants