The canonical answer to this would be simply:
pipenv run tests
Your Pipfile's syntax is correct and this is the only way to run scripts.
If pipenv run tests
don't work, something else is wrong with your setup.
Make sure you at some point have ever run pipenv install
, you can safely run that again to be sure, or pipenv update
if you need to lock and sync again.
Also make sure that when you type pipenv
in your shell you're using the proper pipenv. Some Python setups end up forcing you to call it like one of those following ways:
$ pipenv
$ python3 -m pipenv
$ pyenv exec python -m pipenv
$ ~/.local/bin/pipenv
That happens because most users may and probably have more than one python interpreter, more than one pip, more than one pipenv, and so on, in such a way that you may never know which site-packages and virtualenvs simply typing pipenv
will give you.
For example, if you issue these commands on Linux:
$ pip install --user pipenv
$ sudo pip install pipenv
$ python3 -m pip install --user --upgrade pip pipenv
$ pip3 install pipenv
You will have at least two pipenv installations in your system and which one is called when you type in pipenv
will depend on how your operational system handled those commands and which post installation triggers were performed.