Expert wanna be
Expert wanna be

Reputation: 10624

Python making command and arguments shorten

I run >python -m unittest discover test/vx/ -v this command for running all unit tests in my project folder.

and I want to make the command shorter like,

>python run-all-tests

If I run that command, I wish it runs >python -m unittest discover test/vx/ -v, like shortcut.

How can I make it possible? (I'm using Mac)

Upvotes: 0

Views: 104

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201497

I have a better (and easier) solution.

alias run-all-tests='python -m unittest discover test/vx/ -v'

Then you can simply say

run-all-tests

Without the python at the front. Add the alias to your $HOME/.bashrc so it "persists".

Alternatively, you could write your own shell script and check the argument is run-all-tests if it is invoke the desired behavior. Otherwise, invoke the real python. I don't much like that approach, so I'd stick with the alias.

Upvotes: 2

Related Questions