1

Probably a very basic question for bash experts but I have a test.sh script.. Which has things like

python -m pytest tests/foo.py
python -m pytest tests/bar.py
python -m pytest tests/foobar.py

I am trying to like just put all these in a for loop containing only [foo.py, bar.py.. ]

What would be the simplest way to do this?

2 Answers 2

6

It's a simple for loop

for test in foo.py bar.py foobar.py
do
    python -m pytest "tests/$test"
done
Sign up to request clarification or add additional context in comments.

Comments

1

Adding to Barmar's answer, incase you want to traverse through all files in tests directory:

for test in tests/*
do
    python -m pytest "tests/$test"
done

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.